我有這樣的格式的字符串。我想匹配在開始時沒有abcd
的字符串。如果不包含某種模式,我如何匹配所有內容?
abcd.efgh.ijkl
pqrs.efgh.ijkl
xyz.efgh.ijkl
我想出了這個表達式(?<!abcd).efgh.ijkl
http://rubular.com/r/jyZMIJxoNz
還挺做什麼,我需要的。它匹配pqrs.efgh.ijkl
和xyz.efgh.ijkl
的.efgh.ijkl
部分,並忽略abcd.efgh.ijkl
。但我也希望它匹配pqrs
和xyz
部件。
我試圖做這樣一個條件像這樣(?(?<!abcd)|.*\.efgh.ijkl)
但它甚至不被識別爲正則表達式。語法有什麼問題? ?這豈不是說:「如果它開始與ABCD然後blank
其他匹配一切都交給.efgh.ijkl
@juergend:不是。 '^'是「起始行」錨點,所以'^(abcd)'將匹配以'abcd'開始的任何內容。 – 2012-04-24 10:00:35
哪種語言? – noob 2012-04-24 10:01:37