Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with simple regex search

Status
Not open for further replies.

unomateo

IS-IT--Management
May 9, 2006
38
0
0
US
I'm trying to find the link in a webpage.

given this link:
Code:
<a href="[URL unfurl="true"]http://test.com"[/URL] title="title text">test link </a>
this works and I am able to find the link in the page:
Code:
$search = "|<a href=\".*\".*</a>|";

but if there is a <br> in the link:
Code:
<a href="[URL unfurl="true"]http://test.com"[/URL] title="title text">test<br> link </a>

it stops working. I'm pretty sure it is the < and/or the > in br.

how can I make my search string handle all characters inside the <a and </a> tags
 
that should work.

is there a line break in the source code? have you tried adding the m and s modifiers to your regex?


 
yeah, I think that there is a line break.

I'm runnging this on wordpress posts and I think wordpress adding a line break.

the source code shows <br /> but looks like this:

this fails:
test<br />
link

this works:
test<br />link

how do I match line breaks?
 
looks like the /s modifier does the trick

Thanks for your help
 
yup. the s modifier tells the dot to match all including line breaks. otherwise the dot will stop at the end of the source line.

odd that you should post about wordpress - i've just finished a very cool plugin that converts WPW to use PDO (i.e. sqlite and others) and another very complex version that starts the conversion of WP to a CMS.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top