Meir Yanovich am Dienstag, 29. August 2006 11:41: > e > > hello all
Hello Meir Yanovich > i have string that i need to parse something list that : > <form name="CustomerStatus" action="<% env.GetURI %>" > method="post"<$if(blah)%> name="<% env.get("StatusList") %>" ><% hello > %><input type="hidden" name="<% env.get("Operation") %>" value=""> > > now im selecting the the string part with lazy regexp selection : > > some thing like that : > > (<%.*?%>) > > but now im stack if say i like to loop throw all the matching string > parts and do something with that selection and then put the modified > selection back to place ? > > how can i ? Here is a skeleton; it will fail if tags can be nested or contain the string '%>'. #!/usr/bin/perl use strict; use warnings; my $input=q( <form name="CustomerStatus" action="<% env.GetURI %>" method="post"<$if(blah)%> name="<% env.get("StatusList") %>" ><% hello %><input type="hidden" name="<% env.get("Operation") %>" value="">); # This sub should handle the code and emit a string: # sub handle { my $string_inside=shift; # handle $string_inside # now return what should be the replacement; here dummy: return "[REPLACEMENT for $string_inside]"; } $input=~s/(?:<%)(.*?)(?:%>)/ handle($1) /gse; warn "\nResult text:\n", $input; __END__ Hope this helps. Dani -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>