我需要用正则表达式匹配两个 ipaddress/hostname :像 20.20.20.20
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_]。这里我还要去掉“_”下划线。我尝试了不同的组合,但未能成功。请帮我解决这个正则表达式。