i ve a text is.
"%26lt;s%26gt;111%26lt;/s%26gt;222 avd"
"%26lt;s%26gt;110%26lt;/s%26gt;224 avd"
"%26lt;s%26gt;523%26lt;/s%26gt;221 njh"
if i want a cut %26lt;s%26gt;....%26lt;/s%26gt;
how can i use a Perl Regular Expressions for cut it?
this is a result i want.
"222 avd"
"224 avd"
"221 njh"
Please tell me how can i use a Perl Regular Expressions.
Thanks
Perl Regular Expressions help me please?
Assuming you're reading the text from STDIN, there you go:
while(%26lt;%26gt;) {
s|%26lt;s%26gt;(.*?)%26lt;/s%26gt;||gi;
print $_;
}
Or, if you work on a string variable,
$s =~ s|%26lt;s%26gt;(.*?)%26lt;/s%26gt;||gsi;
Second form is actually better, as it will take care of %26lt;s%26gt;...%26lt;/s%26gt; stretched over multiple lines.
g = globally (replace all occurrences)
i = case-insensitive (will match %26lt;S%26gt;)
s = treat entire text as single line
? = non-greedy (will not merge multiple %26lt;s%26gt;...%26lt;/s%26gt; per line)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment