Best answer

Return all regex matches?

  • 17 March 2020
  • 8 replies
  • 1374 views

Hi all,

I’m trying to extract all text that matches a pattern from an email, but Formatter only returns the first match. Am I missing something? I want to add all matches as Google Sheet rows.

Thanks!

icon

Best answer by Danvers 20 March 2020, 13:13

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

8 replies

Userlevel 7
Badge +12

Hi @jpfm, sorry for the delay in getting back to you on this!

The Formatter Extract Pattern action will only return the first item that matches the pattern, I’m sorry about that. 

 

​We do have an open feature request to add that function and I've added you as another vote for this addition. That lets the team know how many users are interested in the update and also means that we will send you an email if we have an update on this.

 

In the meantime, this should be possible with a code step though I have to confess that I don’t know what that would look like. You could try asking in our Developer Discussion to see if anyone has any ideas.

Hi, I have just noticed this limitation too. Surprised that returning all matches isn’t included in the software.

@jpfm, did you manage to resolve this, or find a workaround? 

 

@Danvers I would like to +1 this feature request please!

Userlevel 7
Badge +11

Hi @nppad!

I’ve gone ahead and added your vote for that feature request as well :)

Userlevel 1

@Danvers @nppad 

I saw you two were using Regex, I’ve got a Regex code that works in regex101, but won’t find the match when I use it in a zap.

 

I was wondering if you could tell me if I’ve got some simple formatting issue that I’m missing.

 

^\s*(?<name>.+)\scompleted
 

This exact code works in Regex101 and Integromat but not in Zapier. 

https://regex101.com/r/XfR6Jx/1

any help would be greatly appreciated.

Userlevel 3

Dropping in seeking the same thing. Need to use RegEx to format multiple links.

Userlevel 7
Badge +11

Hi @Coach Mike!

Though we don’t typically dive too deeply into RegEx (it really can be quite a rabbit hole), with a few tweaks I managed to come up with something that works:

\s*(.+)\scompleted

Check it out:

And in a Zap:

Hope that helps!

Userlevel 3

We were able to do it with a javascript snippet! 

 

const { text } = inputData;const regex = /(\[[^\]]+\])(\([^\)]+\))/g;const result = text.replace(regex, (_, match2, match1) => {  const m = match2.replace(/[\[\]]/g, "");  const n = match1.replace(/[\(\)]/g, "");  return `<${n}|${m}>`;});output = [{ result }];

 

 

Userlevel 7
Badge +12

@jpfm - You might want to check out my integration which will allow you to achieve that.