On Thu, Dec 11, 2003 at 09:05:20AM -0500, Jeff 'japhy' Pinyan wrote: >On Dec 10, George Georgalis said: > >>giving my perl a retry, I found some hints on a website to recursively >>replace text >> >>perl -p -i -e 's/old\(.\)atext/new\1btext/g;' $( find ./ -name '*.html' -o -name >>'*.txt' ) > >This isn't recursively replacing text; it's recursively going through a >directory tree. > >>but from what I can tell, perl doesn't support the \1 for \(*\) symbols >>like sed does. What is the work around? > >Because Perl is not sed. Perl uses (...), not \(...\) for its memory >capturing. In Perl's regexes, all non-alphanumeric metacharacters don't >use backslashes. That means [...] for character classes, not \[...\], and >+ for " 1 or more", not \+, and so on.
that's what I needed to hear... however replacing text (with memory capturing) is still a problem: perl -p -i -e 's/451(.)8229/331\12027/g;' $( find ./ -type f -name '*.html' -o -name '*.txt' ) here I'm trying to replace instances of of a phone number, that might use "-" " " or "." to separate the first and second parts. 451-8229 to 331-2027 451 8229 to 331 2027 etc the result "331P27" hinted 3 digits may be used for the call back perl -p -i -e 's/451(.)8229/331\0012027/g;' $( find ./ -type f -name '*.html' -o -name '*.txt' ) that puts the characters where they go but the dash has changed to some other character (an ascII 001 I suppose). // George -- GEORGE GEORGALIS, System Admin/Architect cell: 646-331-2027 <IXOYE>< Security Services, Web, Mail, mailto:[EMAIL PROTECTED] Multimedia, DB, DNS and Metrics. http://www.galis.org/george -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>