我使用正则表达式对数据进行排序分组。线条看起来有点像正则表达式 - 跳过表情和解析其余
testword test
test testword
tes.w. tes.
tes tes.w.
tes.w othertexttobefound
sometexttobefound testword somemoretextwhichdoesnotmatter
字test
要和发现的othertexttobefound
和sometexttobefound
。
现在我想告诉我的解析器,它应该清楚地忽略testword
及其衍生物,而搜索和专注于我的数据条目的其余部分。 “好词”和“坏词”可以在每行中的任何地方。
我试图[^w]
这是罚款字符串的开始,但在我的版本中没有的其他案件。另外(?:w)
没有做到这一点。我不能使用lookarounds,因为这样可以防止整条线被检测到。
在这里,我希望能为帮助在互联网上进行长时间搜索后!
预先感谢您!
Gerit
从Naxos84大加赞赏的帮助后,我加入了一些德国的现实生活中的例子:
sozialabgabe sozialarbeiter
soz.abg. sozialarbeiter
sozarbeiter soz.abg.
sozialarbeiter otherirrelevantstuff
otherirrelevantstuff soz abg
otherirrelevantstuff sozabg
otherirrelevantstuff sozialabgabe
如果我搜索与
sozial["^\ab"]|soz["^\ab"]|sometexttobefound|othertexttobefound
线6,7得到标记以及,但我不想要这些。
我在做什么错? 谢谢你的进一步提示。
链接: regexr
你说的是一个Perl程序或PCRE Perl的正则表达式引擎? – simbabque
要匹配整个单词,请使用'\ b'作为单词边界。例如:'/ \ BTEST \ B /'将匹配 “测试”,而不是 “testword” 或 “wordtest” 或 “wordtestword”。单词边界可能出现在行的开头和结尾。 – shawnhcorey
@simbabque,有没有这样的事,作为一个“PCRE Perl的正则表达式引擎”。我认为你的意思是“PCRE正则表达式引擎”。 – ikegami