I am trying to replace a string that is surrounded by non word characters.
My target string is
;ab.ab,abb...
And I want to get result of
;[ab].[ab],abb...
Here is my pattern
s/([^\w]+)(ab)([^\w]+)/$1[$2]$3/g
But it does not replace second match because first match is ;ab. and second match is done on tail of ab,abb…
Any ideas?
How about just use the word-boundary?