Help with Regex

Hi there,

I wanted to get some help with Regex. I am building a workflow to extract from a link the two components, the url and the description.

Example: I have this in a field
<a href=https://bubble.io/ target=_blank>This is bubble</a>

I want to extract:

  • https://bubble.io/’ and copy to one field and
  • “This is bubble” and copy to another field

I know how to build the workflow, I am just not sure of the regex that I would use. Any help would be appreciated

Thanks

Frank

1 Like

I have the regex for both parts

((\b(https?|ftp|file)://)?[-A-Za-z0-9+&@#/%?=~|!:,.;]+[-A-Za-z0-9+&@#/%=~_|])
and
<a.+?>(.*?)</a>
which seems to be working in https://regex101.com/

But when I use these expressions in bubble, I am not getting the result that I am expecting


Any thoughts on what is going wrong here?
Thanks in advance
Frank

Use this as the reg ex expression, where “This is” and “sentence” are the two components surrounding the string to extract.

(?<=This is)(.*)(?=sentence)

I find this link really helpful for this kind of regex.

In your example, I’d use:
(?<=href=)(.*)(?= target)
and
(?<=blank>)(.*)(?= </a>)

You may need to escape the = after href and the > after blank by adding a \ in front of it. This should get you close. Also, if that doesn’t work, you can extract some of the text with this and then find & replace.

1 Like

Thanks @david17 I was looking for something like this and this post helped.

@frankstillone I had to add escape chars like this to get what you wanted. If you haven’t figured that out already. fyi.

(?<=_blank>)(.*)(?=</a>)

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.