我尝试构建一个可以匹配成对正斜杠的正则表达式(例如/something/
),但是跳过转义对(例如\/something\/
)并且还跳过后续URL&#39之类的内容; s(例如http://something.com and stuff http://somethingelse.org
)。
因此,在下面的例子中,只有文字"跳过"将匹配,没有别的匹配:
The quick brown fox /jumped over/ the lazy dogs. He was looking for a \/website\/ to help him find ways around the dogs because he was sick of \/jumping\/ over them. Unfortunately, both http://routesaroundlazydogs.com/ and https://maps.lazydogs.com/stuff/things/findmap.aspx were both down on the day he was looking.
正则表达式必须使用Javascript(即没有后视)。
答案 0 :(得分:1)
答案 1 :(得分:1)
答案 2 :(得分:0)
棘手,因为您可能希望foo /bar/ foo /bar/ foo
与/ foo /
不匹配。
我建议找一个url正则表达式,然后执行input.replace(urlRegex, "")
,然后编写一个简单的解析器来读取/
对而不是正则表达式。