Hello I have a RegEx that allows up to 18 characters with numbers, letters and spaces only.
How can I modify this to check if the string is starting with a space, or has two spaces in a row?
/^[0-9A-Za-z\s]{1,18}$/
I am using this regex in both native javascript (not jquery) and PHP.
您可以使用否定前瞻来检查字符串是否以空格开头或是否有 2 个或更多连续空格,例如:
^(?!.*\s{2,})(?!^ )[0-9A-Za-z\s]{1,18}$
(?:(?![ ]{2}).)+
use this regex. This may solve your problem.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.