php - Trying to stop regex at a tag -


i know there other posts similar name i've looked through them , haven't helped me resolve this.

i'm trying head around regex , preg_match. going through body of text , each time link exists want extracted. i'm using following:

$reg_exurl = "/(http|https|ftp|ftps)\:\/\/[a-za-z0-9\-\.]+\.[a-za-z]{2,3}(\/\s*)?/"; 

which works fine until finds 1 has <br after it. url plus <br means doesn't work correctly. how can have stops @ < without including it?

also, have been looking everywhere clear explanation of using regex , i'm still confused it. has guides on future reference?

\s* broad. in particular, inject code url like:

http://hax.hax/"><script>alert('haaaaaaax!');</script> 

you should allow characters allowed in urls:

[-a-za-z0-9._~:/?#[]@!$&'()*+,;=]* 

some of these characters allowed in specific places (such ?) if want better validation need more cleverness


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -