我需要「測試」後到來的特定字符串匹配JavaScript的正則表達式匹配任何
- 前提是有一個(所以避免匹配「測試」獨)
- ,避免比賽如果該字符串是專門字母 「L」
像這樣
testing rest -> matches (rest)
testing what -> matches (what)
testing Loong -> matches (Loong)
testing N -> matches (N)
testing L -> this is not matched
testing LL -> matches (LL)
testing J -> matches (J)
testing -> this is not matched
testing -> this is not matched
testing L TY -> this specific string will not occur so it is irrelevant
並加上引號
"testing rest" -> matches (rest)
"testing what" -> matches (what)
"testing Loong" -> matches (Loong)
"testing N" -> matches (N)
"testing L" -> this is not matched
"testing LL" -> matches (LL)
"testing J" -> matches (J)
"testing" -> this is not matched
"testing "-> this is not matched
"testing L TY" -> this specific string will not occur so it is irrelevant
我該怎麼做?
也許['/ ^「?testing(。{2,}?)」?$ /'](https://regex101.com/r/wI8cY2/2)? –
好吧,也許['/ ^「?testing((?!\ s * L?\ s * $)。*?)」?$ /'](https://regex101.com/r/wI8cY2/3) ? –
'/ ^「(testing(?:)?。*)」$ /' - https://regex101.com/r/cW1dK1/2 – ThePerplexedOne