I have an question about regular expressions. I want to use it to change text starting with http://, www and ending with .extention to a clickable link using regular expressions. Usings a calculation field.
There are a few issues in your code. First of all a regexp definition is not a string. You put the regexp definition between forward slashes.
Also to apply the matched text in the resultstring you need to prefix them the dollar sign ($1 to $9) and put your regexp definition that corresponds with that between parenthesis.
Last issue is that a replace function returns the result.
So when you fix this then your code looks something like this:
The forward slashes are not really mandatory but preferred as far as I know.
The * or + signs will search for 0 or more or 1 or more occurences.
The problem I see is that you have no end defined so your will search in an eager way without limit.
Maybe it is better to search for a space at the end when your url is part of a text (if not you can disregard).
You then also need to make the regex ‘non eager’ by replacing the .* with .?.
You regex would become:```
/(http://.?\s)/
Ok but I use the string.match(/(http://.*?)(\s)/g) now.
But It only works with an whitespace at the end of the url.
Is it possible to do it without the whitespace also?
Yes, but now you have to start reading documentation!
You can replace (\s) with (\s?) or when you need more characters you could do (\s|.)? and any type of variation.
But again, you need to pick up some documentation now because this could end up in an endless thread (and therefore will not end otherwise it would not be endless)…