正则表达式
问题描述:
我是新手到regex
这里是我的问题:正则表达式
下面是该文件的内容:
cts-pdr/comment-primary/:not spamming
cts-pdr/comment-primary/:please remove since not spamming
cts-pdr/comment-primary/:not spamming
cts-pdr/comment-primary/:not spamming
cts-pdr/comment-primary/:Not spamming
cts-pdr/comment-primary/:not spamming
cts-pdr/comment-primary/:please unblock since not spaming
我想在这里实现的是的第二部分匹配结肠。 我想拍摄整个字符串即:
(please\s.*)? [N|n]ot .*
我不能得到正确的匹配。 任何人都可以帮忙吗?
答
你可以做的是更新您的正则表达式:
而且mabye使用非捕获组(?:
,如:
这将匹配please
或Not
或not
后跟任意字符零次或多次.*
+0
这工作(?:请| [N | n] ot)。* 感谢您的帮助:) – Farid
+0
@Farid欢迎您,很高兴我可以帮助。你总是可以考虑[接受答案](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work)。 –
这里不需要正则表达式。拆分冒号并参加第二部分。 –
你可以编辑你的问题,有一个无用的标题,实际上试图描述你在问什么? –
正则表达式是过度的。这是一个简单的使用分裂任务,正如@SergioTulentsev所说。 –