如何在javascript中制作正则表达式来重复(how to make an regular expression in javascript to repeat)
如何使其验证此字符串:
word:word,word:word,我写的这篇文章仅适用于:
word:word,enithinggg这是错的。
/^(^([0-9a-zA-Z!\? ])+\:([0-9a-zA-Z!\?. ])+\,)+$/iHow can I make it to validate this string:
word:word,word:word,What I wrote this and works only for:
word:word,enithingggwhich is wrong.
/^(^([0-9a-zA-Z!\? ])+\:([0-9a-zA-Z!\?. ])+\,)+$/i最满意答案
/^(([0-9a-zA-Z!\?])+\:([0-9a-zA-Z!\?])+\,?)+$/
应该这样做。 你在第一组中有^ ,强迫它匹配换行符。 我对javascript正则表达式不太熟悉,所以我不确定最后i在做什么。
您可以在http://rubular.com上运行快速测试
/^(([0-9a-zA-Z!\?])+\:([0-9a-zA-Z!\?])+\,?)+$/
should do it. You had ^ inside the first group, forcing it to match a newline. I'm not too familiar with javascript regular expressions, so I'm not sure what the i at the end was doing.
You can run quick tests on http://rubular.com
更多推荐
发布评论