![](/img/trans.png)
[英]Javascript regex to find a pattern in a string, excluding a possible preceding word match
[英]javascript regex match the string excluding ending pattern
誰能幫我這個忙:
我堅持使用JS正則表達式。
我有一個像這樣的字符串:
idont 測試 33lkjrhguegh8438934hihfer TEST2 oidchschds
我想匹配test
和TEST2
之間的所有內容(不包括TEST2
。
因此,預期輸出為:
測試 33lkjrhguegh8438934hihfer
我嘗試了以下沒有成功的方法:(:
(test)(.*)(?:(?!(TEST2)))
(test)(.*)(?:(TEST2))
(test)(.*)(?:(?!TEST2))
(test)(.*)(?:TEST2)
(test)(.*)(TEST2) //almost works but selects TEST2 also
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.