in reply to Perl command line search and replace
You will also want to check those regular expressions. As they are they won't even compile. URLs contain lots of /s so you will probably want to choose a different delimiter, for example | or {}. Don't forget that . and ? are regex meta characters.
Something along the lines of will be better
By using the \Q \E pair you remove the need for most of the \ escapes and let perl handle the special characters. Aligning the replacement text with the original text also makes it easier to see what you are changing (I'm assuming that you have been convinced to put this in a file).s{\Qhttp://www.mydomain.com/script.pl?key=3\E} {http://www.mydomain.com/script.pl?key=4} s{\Q<font color="blue">\E} {<font color="red">}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl command line search and replace
by Anonymous Monk on Jun 28, 2011 at 16:38 UTC | |
by Anonymous Monk on Jun 28, 2011 at 17:54 UTC |