正则表达式查找不以 " 或 ' 开头且以 space 结尾的单词

Regex find word NOT starting with " or ' AND ends with space

我一直在尝试创建一个正则表达式来查找不以 " 或 ' 开头并以 space 结尾的单词。

这是我目前所拥有的:

\b(?![i|"|'])test.([^\s,]+)

测试数据

SHOULD WORK -> test.something test.somethingelse.another  // 2 Matches This is correct

SHOULD NOT WORK ->  one.test.two  // 1 mathces should be 0 is not the start of word

SHOULD NOT WORK -> "test.shouldnotbeselected 'test.something  //2 matches should be 0 has ' or "

NEGATIVE LOOK AHEAD WORKS WITH "i" and not with quoutes    I don't know why  -> 
itest.doesnottake  'test.doesnottake "test.doesnottake // 2Matches should be 0

如有任何帮助,我们将不胜感激。 提前谢谢你。

您可以使用

(?<!\S)test\.(\S+)

参见regex demo详情:

  • (?<!\S) - 左侧空白边界
  • test\. - test. 字符串
  • (\S+) - 捕获第 1 组:任何零个或多个空白字符,尽可能多。