0

How can I make it to validate this string:

word:word,word:word,

What I wrote this and works only for:

word:word,enithinggg

which is wrong.

/^(^([0-9a-zA-Z!\? ])+\:([0-9a-zA-Z!\?. ])+\,)+$/i
4

1 回答 1

0

/^(([0-9a-zA-Z!\?])+\:([0-9a-zA-Z!\?])+\,?)+$/

应该这样做。您^在第一组内,迫使它匹配换行符。我对javascript正则表达式不太熟悉,所以我不确定i最后在做什么。

您可以在http://rubular.com上运行快速测试

于 2013-06-04T21:15:40.117 回答