当前位置: 动力学知识库 > 问答 > 编程问答 >

java - I need a Regex, that which accepts only a String(with only Alphabets and Numbers) with spaces allowed at the start and end, but not in between?

问题描述:

^[A-Za-z0-9]*[A-Za-z0-9\f\t]$I tried using this, but it is not accepting strings with a space at the end. I am trying to make some server side validation using Regex for this case in Java.

网友答案:

Just add optional spaces at the beginning and at the end:

^\s*[A-Za-z0-9]+\s*$
网友答案:

This should work

\s+[\w\d]+\s+
分享给朋友:
您可能感兴趣的文章:
随机阅读: