I'm betting you don't get to dictate that the string has no newlines in it.
--
A principle is an instruction in qualitative endeavour.
http://www.hacksaw.org -- http://www.privatecircus.com -- KB1FVD
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED
-
De: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Date: mardi 25 novembre 2003 09:20
À: [EMAIL PROTECTED]
Objet: Regular Exprections
I have this string
my $str =
'aaa
--%%
bbb
%%--
ccc
--%%ddd%%--';
And I need to remove every thin bettewin '--%%' and '%%--'.
Lets
Hacksaw wrote:
>
> $str =~ s/--\%\%.*?\%\%--/--\%\%\%\%--/sg;
You don't need all those backslashes. This works as well (and IMHO is
easier to read):
$str =~ s/--%%.*?%%--/----/sg;
Alan
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
t.pl:
#!/usr/bin/perl -w
my $str =
'aaa
--%%
b%b
%%--
ccc
--%%ddd%%--';
$str =~ s/--\%\%.*?\%\%--/--\%\%\%\%--/sg;
print $str, "\n";
--
hacksaw > perl t.pl
aaa
----
ccc
----
--
All the magic is in the matching operator.
The ? after the .* makes it match the
I have this string
my $str =
'aaa
--%%
bbb
%%--
ccc
--%%ddd%%--';
And I need to remove every thin bettewin '--%%' and '%%--'.
Lets say /--\%\%[^\%]*\%\%--/ works more or less. The problem is if I have
my $str =
'aaa
--%%
b%b
%%--
ccc
--%%ddd%%--';
Who can I resolve this problem?
Thanks
Marcos