Teddy, Well, this works, I've tested it, --------------------------------------- my $test = qq^ <a href="/index.shtml" title="index file"> Index </a> <a href="/about.shtml" title="about my site"> About </a> ^;
$test =~ s/href\=\"(.*?)\"/href\=\"another_text_$1\"/g; print $test; ----------------------------------------- The reason the other even with an /s did not work was because we told it to treat the whole text as a single line when running the expression on it, but that doesn't mean it stripped out the line breaks. Basically it just chose to ignore their function, but the line breaks themselves are still in there as valid characters. So, there are two solutions. The one above where you only check the href="(.*?)" part, or you could strip out [\n\r]+ from the string before running your pattern match on it. There was one last problem. What you gave was href="(.*)" which does not have a question mark. The question mark tells the expression to not be greedy which means that the .* will not stop matching when it finds the next quote, not the last quote. So where in your case, you had multiple links, it was finding the last quote in the whole string, not the closing quote of that particular href= . Regards, David ----- Original Message ----- From: "Octavian Rasnita" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, July 01, 2002 11:20 PM Subject: Re: Help! which are the correct parameters? Unfortunately it doesn't work this way. I've tried using the /s modifier in the following example, and only the first <a href="..."> is modified. my $test = qq^ <a href="/index.shtml" title="index file"> Index </a> <a href="/about.shtml" title="about my site"> About </a> ^; $test =~ s/<a href="(.*)">/<a href="another_text_$1">/gs; print $test; Teddy Center: http://teddy.fcc.ro/ Mail: [EMAIL PROTECTED] ----- Original Message ----- From: <[EMAIL PROTECTED]> To: "Octavian Rasnita" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Monday, July 01, 2002 7:37 PM Subject: Re: Help! which are the correct parameters? my $stuff = qq^ here is some stuff and more stuff to boot stuff for me and stuff for you ^; $stuff =~ s/stuff/money/gs; # g says match all occurrences # s says treat $stuff as a single line Regards, David ----- Original Message ----- From: "Octavian Rasnita" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, June 28, 2002 9:57 AM Subject: Help! which are the correct parameters? Hi all, I want to use regular expressions to match all the links from a web page. I am fighting for a long time but with no results. I don't know what modifiers I need to use for matching all the links even though some of them use multiple lines. I want to also match a link like: <a href=http://www.server.com/dir/file.shtml title="Test link"> This is a test only </a> Without the /m modifyer, my regexp matches only the first link that is on a single line. With the /m modifyer, the regexp matches all the links that don't span on multiple lines. But the links that span on multiple lines can't be matched. I've tried the following regexp: $link =~ s/(<a href=".*">)/<a href="http\:\/\/MyServer\.com\/cgi-bin\/script\.pl\?page=$1">/mgi; Thank you for any idea. Teddy Center: http://teddy.fcc.ro/ Mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]