我需要用正則表達式匹配兩個ip地址/主機名: 像20.20.20.20IP地址/主機名匹配的正則表達式
should match with 20.20.20.20
should match with [http://20.20.20.20/abcd]
should not match with 20.20.20.200
should not match with [http://20.20.20.200/abcd]
should not match with [http://120.20.20.20/abcd]
should match with AB_20.20.20.20
should match with 20.20.20.20_AB
目前我使用這樣的正則表達式:"(.*[^(\w)]|^)20.20.20.20([^(\w)].*|$)"
但它不適用於最後兩種情況。由於「\ w」等於[a-zA-Z0-9_]。這裏我也想消除「_」下劃線。我嘗試了不同的組合,但無法成功。請用這個正則表達式來幫助我。