我有以下可能的文本:
Any text here!
Any foo text here!
Any text foo here!
Any text here foo!
并希望我的比赛始终是:
Any text here!
我已经尝试了打印两个捕获组($1$2
(/(.+)(?!foos)?(.+)/g
模式,但没有成功,因为.*
占据了foo
部分。 第一个问题是是否可能,seccond将如何?
尝试以下操作:
(?(?=.*foo)(.+)(?:sfoo)(.+)|(.+))
组 1 和组 2 (($1$2)
( 给出从第 2 行 - 第 4 行Any text here!
组 3 提供第 1 行的Any text here!
1 Any text here!
2 Any foo text here!
3 Any text foo here!
4 Any text here foo!
雷正表达式101演示