Thread Regexp global schalter (4 answers)
Opened by esskar at 2004-03-16 12:59

esskar
 2004-03-16 12:59
#81034 #81034
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
Code: (dl )
1
2
3
4
5
my $string = "http://www.ams.net";
$string =~ s!(.*)!<a href='$1'>$1</a>!g; # g für global
print $string;
^Z
<a href='http://www.ams.net'>http://www.ams.net</a><a href=''></a>


wieso wird 2 mal eresetzt? erklärungen sind gewünscht!

Code: (dl )
1
2
3
4
5
my $string = "http://www.ams.net";
$string =~ s!(.+)!<a href='$1'>$1</a>!g;
print $string;
^Z
<a href='http://www.ams.net'>http://www.ams.net</a>


funzt natürlich!

View full thread Regexp global schalter