Re: Regex

From: Date: Sat, 15 Sep 2001 19:32:06 +0000
Subject: Re: Regex
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-67459@lists.php.net to get a copy of this message
preg_match('/<a href="(.*?)"/i',$str,$reg); Your URL will now be in $reg[1] -Rasmus On Sat, 15 Sep 2001, Boaz Yahav wrote: > Hi > > How does one extract a URL from HTML like : > > <a href="/abc/def/0,1234,567.html?xxx=abcde" class="MyClass"> > > I have an HTML file with many lines like this and I want to extract the > /abc/def/0,1234,567.html?xxx=abcde part from each one. > Assuming I can get the lines into an array, how can I extract only the > URL part? > > I tried ereg but I'm not a wizard with RegEx. > > This is what I played with but I'm not sure how I can extract only the > URL > > If(ereg("<a href=",$Array[$i],$regs)){ > Echo $regs[0] . "<BR>"; > } > > > thanks > > berber > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#67459) next »