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
/^(([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
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.