我需要用正则表达式匹配两个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_]。这里我也想消除“_”下划线。我尝试了不同的组合,但无法成功。请用这个正则表达式来帮助我。