Best answer

Trouble with Regex code

  • 28 February 2023
  • 3 replies
  • 109 views

Hey guys,

I’m struggling with the Regex code in a formatter Zap. I’m trying to extract the “Name” attribute from the following string, but my regex code doesn’t seem to work in Zapier, as I keep getting an empty result.

 

“Name: Tester E-mail: Tester@gmail-email-com.com


This is my formula:

/(?<=Name: )(.*)(?= E-mail:)/g

 

Can anybody spot my error?

 

Help would be much appreciated!

icon

Best answer by nicksimard 28 February 2023, 19:58

View original

3 replies

Userlevel 7
Badge +11

Hi @jojo69!

So in the text you showed, are you only interested in getting the word “Tester”? And will the data always come in that same format?

If so, this should work for you (I used Chat GPT to get the answer because RegEx eludes me, no matter how hard I try haha):

(?<=Name: )\b\w+\b

Userlevel 7
Badge +14

Hi @jojo69 

Good question.

Some other options:

  1. You can use multiple Formatter > Text > Split steps to isolate the desired value.
  2. You can use OpenAI > Send Prompt to have AI isolate the desired value.
  3. You can use a Code step:

 

Thanks @nicksimard, that did the trick!

 

Cheers

Reply