I’m in a situation where I have a string of raw text where I want to find all links (starting with Http://) and place <a href="thelink"> before the start of the link and then a </a> after the link. The problem is, that I don’t know when the link ends. I.e.:
In the above example, I am able to find the start of the link: http:// but I don’t know when the link ends, so it would take the ) aswell.
Can anyone shed some light on this? Should I be using some sort of a RegEx pattern?
Thanks a lot in advance.
All the best,
Bo
According to RegexBuddy use this as your regex
and this as your replace syntax
The logic is to look for all valid URL characters and stop once you encounter an invalid one like a space or a right parenthesis, for example.
If you haven’t tried out their tool, I highly recommend it. It’s a great learning tool as it dissects regular expressions and converts them into plain English.
It also comes with a huge library of useful expression such as this one and it’s quite cheap.