Title: Regex Newbie Q: Non-Trivial Substitution and Modifying the MatchedString
"Veli-Pekka Tätilä" wrote, on Sun 10/9/2005 15:58
: Yet another newbie question about regular expressions:
: I'd like to find and replace bits of text as usual. However, rather than
: replace all occurrences in one quick swoop using the s-operator and the
: g-flag, the replacement is so complex that it cannot be expressed as a
: straight substitution. So I would have to find a piece of text, process it
: in a separate function, and replace the matched text with the newly computed
: text. This goes on for n interesting matches in the input.

I can't tell from your note if you've investigated the /e flag yet, that allows you to replace a chunk of text with the result of a function call:
 
s/(stuff that's not a note)?(note)/$1tag_from_note($2)/ge;
 
Good luck,
 
Joe
 

==============================================================
          Joseph P. Discenza, Sr. Programmer/Analyst
               mailto:[EMAIL PROTECTED]
 
          Carleton Inc.   http://www.carletoninc.com
          574.243.6040 ext. 300    fax: 574.243.6060
 
Providing Financial Solutions and Compliance for over 30 Years
 
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to