General Community > Scripting Help
help with regex
Anguz:
what would be the regular expression used to find urls in img or anchor tags in an html page?
I thought this one would work
--- Code: ---'/(href|src)=\"(.*)\"/i'
--- End code ---
but it's not working :(
Parham:
try this:
"/((http:\/\/www\.|http:\/\/|www\.)([\w\.\/\=\?\&\-]+))/"
[Unknown]:
'/(href|src)=(["\']?)(.+?)\\2/i'
1 => 'href' or 'src'.
2 => " or '.
3 => the URL.
Or...
'/<(a|img)[^>]+(href|src)=(["\']?)(.+?)\\2/i'
1 => 'a' or 'img'.
2 => 'href' or 'src'.
3 => " or '.
4 => the URL.
-[Unknown]
Anguz:
thank you guys :)
Parham:
oh damn, i completely jumped the gun and gave you the wrong regex... sorry i kept thinking URL URL, not tags. i'll read more carefully next time :)
Navigation
[0] Message Index
[#] Next page
Go to full version