http://www.perlmonks.org?node_id=1005390


in reply to need help to replace string in a line

I haven't checked it, but I guess your extensive use of .*? is causing trouble. That can match lots of stuff you don't want it to match. Be more specific!

For example:

/ nf\w* \h* = \h* \d+ /x # ^ don't make the = optional # ^^^ not arbitrary characters, just allow word characters / nf\w+ \h* = \h* \{ [^}]+ \}/ # ^^^^ don't allow a closing bracket inside the bra +ckets