[英]Regular Expression to match pairs of forward slashes, but not escaped or between subsequent http://
我正在尝试构建一个可以匹配成对的正斜杠(例如/something/
)的正则表达式,但是跳过转义的对(例如\\/something\\/
),并且还跳过类似后续URL的内容(例如http://something.com and stuff http://somethingelse.org
)。
因此,在下面的示例中,将仅匹配文本“ jumped over”,没有其他匹配项:
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(即无后顾之忧)。
棘手的,因为您可能希望foo /bar/ foo /bar/ foo
不匹配/ foo /
。
我建议找到一个url正则表达式,然后执行input.replace(urlRegex, "")
,然后编写一个简单的解析器以读取/
对而不是正则表达式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.