Archive for the 'Technical' Category

Perl: Replacing every instance of a Regex found in multiple files…

Wednesday, May 23rd, 2007

Simply use the following command; perl -pi~ -e ‘s/regexp1/regexp2/’ files Where; regexp1 – Regular expression you are seeking. regexp2 – It’s replacement. files – The files you wish this replacement to occur.

Vim: Counting the number of matches…

Wednesday, May 23rd, 2007

A useful trick in Vim to return the number of matched expressions in a file; let x=0 | g/regexp/let x=x+1 echo x where regexp obviously is the regular expression (pattern) you wish to count.