Skip to main content
Best answer

Return all regex matches?


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!

Best answer by Danvers

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.

View original
Did this topic help you find an answer to your question?
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

Danvers
Forum|alt.badge.img+12
  • Zapier Staff
  • 3731 replies
  • Answer
  • March 20, 2020

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.


  • New
  • 1 reply
  • June 9, 2020

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!


nicksimard
Forum|alt.badge.img+11
  • Zapier Staff
  • 2115 replies
  • June 10, 2020

Hi @nppad!

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


  • Beginner
  • 2 replies
  • July 5, 2020

@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.


brianswichkow

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


nicksimard
Forum|alt.badge.img+11
  • Zapier Staff
  • 2115 replies
  • August 7, 2020

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!


brianswichkow

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 }];

 

 


ikbelkirasan
Forum|alt.badge.img+12
  • Zapier Expert
  • 555 replies
  • August 8, 2020

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