[英]Regex find char '.' except for words starting with @
assuming the following sentence: 假设以下句子:
this is @sys.any and. 这是@ sys.any和。 here @names hello.
在这里@names你好。 and good.bye
和good.bye
how would I find all the '.' 我怎么能找到所有的'。' besides the ones appearing in words that start with @?
除了以@开头的单词出现的那些?
disclaimer, been playing at regex101 for over 2 hours now after reading a few answers on SO and other forums. 免责声明,在SO和其他论坛上阅读了几个答案之后,现在已经在regex101上玩了2个多小时了。
(^|\\s)(\\w*(\\.))+
- this may satisfy the sample text you've posted. (^|\\s)(\\w*(\\.))+
- 这可能会满足您发布的示例文本。 You can find all '.' 你可以找到所有'。' in third group
在第三组
UPDATE: if in your text you have words, started with any other symbol, for instance, #asd.qwe.zxc
, you can improve your reg exp: 更新:如果在你的文本中你有单词,从任何其他符号开始,例如
#asd.qwe.zxc
,你可以改进你的reg exp:
(^|\\s)[^@]?(\\w*(\\.))+
The regex ^@|\\s\\w*(\\.)+
may be used to only find and match periods without @. 正则表达式
^@|\\s\\w*(\\.)+
可用于仅查找和匹配没有@的句点。
See a live example for reference: http://rubular.com/r/gfVY3j16Rx 请参阅实例以供参考: http : //rubular.com/r/gfVY3j16Rx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.