1
我不能在正則表達式中使用@例如:(?is).*\bhello\b.*
匹配hello
,但是
(?is).*\[email protected]\b.*
不匹配@hello
。@ in正則表達式(at-sign)
有人可以向我解釋爲什麼?噢,this也不起作用。
我不能在正則表達式中使用@例如:(?is).*\bhello\b.*
匹配hello
,但是
(?is).*\[email protected]\b.*
不匹配@hello
。@ in正則表達式(at-sign)
有人可以向我解釋爲什麼?噢,this也不起作用。
這是因爲\b
(字邊界)。
\b
一個\w
和\W
字符(或反之亦然)之間的匹配,或之間\w
和字符串的開始/結束。但@
不是\w
字符(而h
是\w
字符)。所以沒有匹配。
什麼是通過這種方式? – hexagonest
@DoorKnob,在'@'之前刪除'\ b'。 – falsetru
然後匹配,例如'hi @ hello'。我不希望它那樣做。 – hexagonest