I can't seem to get the protocol to be optional. I'm trying to get both "http://www.example.com" and "www.example.com" to match. Thanks for any help given.
[edited by: jatar_k at 8:26 pm (utc) on Feb. 5, 2005]
[edit reason] turned off smilies [/edit]
I can't seem to get the protocol to be optional. I'm trying to get both "http://www.example.com" and "www.example.com" to match (as it stands, a match only occurs with http: //, etc. present). I can't get the? in the correct spot, without messing the whole thing up. Optimally, I would like the colon and slashes to be optional too (i.e. http: //).Thanks for any help given.
Have you considered rolling the '://' into your optionals? For example,
(ftp://¦http://¦https://¦gopher://) etc.
Could you explain a bit more what you are trying to accomplish?
Your suggestion might not work, b/c as it stands, the http :// is not optional in that pattern. I need to make it optional.
((^¦[ \t\r\n])(((http¦https¦ftp)\://)?)[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\-\._\?\,\'/\\\+&%\$#\=~])*[^\.\,\)\(\s])
This pattern will match any url, with the protocol being optional. Combine it with some functionality that adds a link, and you've got an auto-activating url.