[英]Two words separated by a space followed by a comma more than one time
我想创建一个用分号分隔任意数量单词的正则表达式。 例如:
word1 word2;word3 word4;word5 word6....
这是我尝试过的:
^.*(;){0,}
但这允许并排使用多个分号。
根据您的评论,您需要一个表达式,该表达式与一串用分号,空格或两者分开的单词匹配。
^(\\w+( ;?|; ?))+\\w+$
说明:
^ | Enforce beginning of string
( | Group the following:
\w+ | One or more consecutive word characters
( ;?|; ?) | A space, semicolon, or combination of the two
)+ | End group; match one or more of them
\w+ | One or more consecutive word characters
$ | Enforce end of string
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.