【发布时间】:2021-07-15 00:06:04
【问题描述】:
我想在 javascript 中创建一个 RegExp。如果字符串非空,则要求在字符串的开头允许空格。另外,我必须在字符串的开头限制一些特殊字符。
目前,我正在使用这个 RegExp -
^(?!^[=+-@]).*
these strings need to be passed from regexp test -
foo
foo bar
bar
123bar
foo@bar.com
these string should fail -
@foo
@foo
' ...spaces'
'' empty-string
请帮忙。
【问题讨论】:
-
试试
^(?! *[=+@-]|\s+$).*
标签: javascript regex