[英]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.