正则表达式:查找具有多个句点的单词
Regex: Find words with multiple periods
我接到一项任务,要求使用正则表达式从段落中查找字符串。我需要找到一个看起来 something.like.this 但不限于 looking.something.like.this.also.[= 的字符串11=]
以上面的段落为例,这个表达式会拉出 "something.like.this" 和 "looking.something.like.this.also"
Must me A-z, no =+[]{}\/?*&^%$#@!*, can include .()-
我想检查一下空格之间是否有多个句点。
Is this regex what you're looking for?
(?:[A-Za-z(\)-]+(?:\.[A-Za-z\(\)-]+)+){2,}
评论中的其他标准
无法匹配 ...
.
This would also match ... which is not included in the OP's requirements. – juharr
@Zsw i didnt think about it, but @juharr is correct, i cannot have ... – Bernie
无法匹配连续的句点。
What about consecutive periods like this..has...multiple....periods
- juharr
@juharr i should also ignore this, but it will be highly unlikely that will appear in any of the text it will run against. – Bernie
无法匹配 one.two
.
@Zsw one.two cannot be matched. I found using [A-Za-z.()-]+.[A-Za-z.()-]+.[A-Za-z.()-]+ works for this, but how do i ignore the ... or this...this..this? – Bernie
我接到一项任务,要求使用正则表达式从段落中查找字符串。我需要找到一个看起来 something.like.this 但不限于 looking.something.like.this.also.[= 的字符串11=]
以上面的段落为例,这个表达式会拉出 "something.like.this" 和 "looking.something.like.this.also"
Must me A-z, no =+[]{}\/?*&^%$#@!*, can include .()-
我想检查一下空格之间是否有多个句点。
Is this regex what you're looking for?
(?:[A-Za-z(\)-]+(?:\.[A-Za-z\(\)-]+)+){2,}
评论中的其他标准
无法匹配
...
.This would also match ... which is not included in the OP's requirements. – juharr
@Zsw i didnt think about it, but @juharr is correct, i cannot have ... – Bernie
无法匹配连续的句点。
What about consecutive periods like
this..has...multiple....periods
- juharr@juharr i should also ignore this, but it will be highly unlikely that will appear in any of the text it will run against. – Bernie
无法匹配
one.two
.@Zsw one.two cannot be matched. I found using [A-Za-z.()-]+.[A-Za-z.()-]+.[A-Za-z.()-]+ works for this, but how do i ignore the ... or this...this..this? – Bernie