href\=\"(.*)\"
this match all links, what i need is to make it apply on all links except when href has localhost as a key开发者_C百科word on it
Thanks.
I think this regular expression does what you want:
href="(.*)localhost(.*)"
preg_replace("@href\\=\\\"((?:\\b[^l\\\"]|l[^o]|lo[^c]|loc[^a]|loca[^l]|local[^h]|localh[^o]|localho[^s]|localhos[^t]\\b)|[\\w&&[^\\\"]]+localhost|localhost[\\w&&[^\\\"]]+|[\\w&&[^\\\"]]+localhost[\\w&&[^\\\"]]+|[^l\\\"])+\\\"@", $replacement, $str)
精彩评论