Forum Moderators: phranque
I have the following regular expression pattern that matches a url:
((mailto\:¦(news¦(ht¦f)tp(s?))\://){1}\S+) This works great and matches most links.
However, I'm trying to modify it slightly so it will also match a string that starts with "www" as well as matching a string that starts with "http" etc as it does currently.
Does anyone have any tips or a regex pattern that will already do this?
Andreas
I've tried many different pattern variations and I just can't come up with what I need.
To clarify, I'm trying to modify this:
((mailto\:¦(news¦(ht¦f)tp(s?))\://){1}\S+)
To also match if it finds something that resembles a link that could start with www. as well as match if it finds something that could also start with [www...] as it does currently.
Thanks.
Also, with a problem as common as this one, you might want to look through CPAN to see if there is a module that does what you're looking for. There are tons of modules to deal with HTML in different ways. Even if you don't want to use the module, I bet you that you can find a good regular expression in one of them.
Good luck!