On Dec 3, 2003, at 12:25 PM, Saskia van der Elst wrote:
I have trouble executing a search and replace through all files in a certain[..]
directory.
I want to replace " _</pat" by "</pat"
Can I match a white-space?
I have tried the following regex:
s/ _\</pat/"</pat"/g
I agree with Tom that you get better mileage by putting your delimiters to something OTHER than a token in the pattern that you are matching.
but there is also the little detail of putting that "\" in the right place.
$_ =~ s/"_\</pat"/"\</pat"/gi; #g for every occurrence, i for
should ahve been
$_ =~ s/_<\/pat/<\/pat/gi; #g for every occurrence, i for
target what you WANT to target and no more.
remember that those double quotes will allow things to be 'interpolated' - which is not what you want.
but also if you had adopted Tom's strategy that line would be a bit more readable as:
$_ =~ s|_</pat|</pat|gi; #g for every occurrence, i for
If you wanted to merely remove the "_" that preceded an angle that closed you could tighten that down with
$_ =~ s|_</|</|gi; #g for every occurrence, i for
you did I think mention perldoc perlre, yes?
you might also want to check out
perldoc perlrequick perldoc perlretut
but some of it is merely 'art' and not science...
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]