• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
preg match help

#1
[eluser]new_igniter[/eluser]
Does anyone have a function on hand for parsing text for links that being with http, www, and grabbing the matches?

I have a bunch of links on my page that begin with http://www.tinyurl.com/[what tinyURL creates] and want to grab those links out of a string of text.

#2
[eluser]mglinski[/eluser]
/^http(.*)\s/

Try that, just add http to the beginning of every match.
Might not work, i dont use preg much.
-Matt

#3
[eluser]sophistry[/eluser]
you pretty much wrote the regex yourself!

Code:
http://www.tinyurl.com/([^\s]+)

that means look for the whole tiny url domain with http:// and then capture anything that is not a space character. this won't work if the urls are in hrefs (as in the urls are in HTML code rather than straight txt) because typically the href uses double quotes to delimit the end of the url. in that case you should be able to just replace the \s with ".

with that in preg_match function you'll have the tinyurl string in array item 1.

let us know.

cheers.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.