Link to home
Start Free TrialLog in
Avatar of popy
popy

asked on

adding stuff in string.....

hi all

i have this string :
<li><a href="/anydir/anylink.html">any text for the link</a>

and i want to get this:
<li><a href="http://www.myserver.com/anydir/anylink.html">any text for the link</a>

do someone have any idea..???

tanks
popy
Avatar of monas
monas
Flag of Lithuania image

$x = '<li><a href="/anydir/anylink.html">any text for the link</a>';

$x =~ s#(<a href=")(.*)#$1.'http://www.myserver.com/'.$2/ei;

print $x;
oops

$x = '<li><a href="/anydir/anylink.html">any text for the link</a>';

$x =~ s#(<a href=")(.*)#$1.'http://www.myserver.com/'.$2#ei;

print $x;
Avatar of popy
popy

ASKER

Adjusted points from 100 to 150
Avatar of popy

ASKER

ok, thanks, but now subquestion, this line appear somewhere in the text, i reading text file, then i need to verifing if the line having this tag...
any sugestion...?

popy
Avatar of ozo
There's really no need for the (.*) .$2 and /e
ASKER CERTIFIED SOLUTION
Avatar of nmoldav
nmoldav

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
while($x = <FILE>){
  $num = ($x =~ s#(<a href=")#$1.'http://www.myserver.com/'#gei);
  # number of occurences is in $num;
}