Best answer

Regex positive lookbehind

  • 19 August 2020
  • 6 replies
  • 183 views

Userlevel 2

Hi !

I am using Zapier to extract data from trello and store them in a google sheet spreadsheet. I mostly used regular expressions and it mostly works.

However, I tried to used the positive lookbehind in Formatter but it doesn’t seem to be working.

What I want is to get numbers after a specific character (:).

 

Here is my string : 

3 dirigeants

Vendredi : 2, Jeudi : 3, Mercredi : 1, Mardi : 2

 

Here’s what I wrote : 

(?<= :)\d+

 

Maybe I made a mistake but I can’t see it… by any chance can someone try to help be understand ?

Thank you very much !

icon

Best answer by ForYourIT 20 August 2020, 22:29

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.

6 replies

Userlevel 7
Badge +7

Hi @Hana_ha ,

If your string always looks like the above, I think you have a small little error here. It looks like you are missing a space after the : sign. Should be like this:

(?<= : )\d+

Does this help you?

~Bjorn

Userlevel 2

Hello @ForYourIT ,

Thank you for you anwser.

Indeed it works better with the space, thank you very much ! I didn’t even notice it :( 

However, I only have the first number in my spreadsheet. Does it means that I can’t have all the numbers in one row ?

 

 

 

Userlevel 7
Badge +7

Hi @Hana_ha I am not sure what kind of workflow you have.

You say you use Trello, but is this information all in 1 card in 1 line? What is the current result & what are your expectations? Having a screenshot of your setup makes it a lot easier as well.

Let me know!
~Bjorn

Userlevel 2

@ForYourIT , you’re right I am sorry I should have put screenshots earlier.

Here is a screenshot of what I have in my card and everything is extracted in the same row:

  • I used 3 different regex to extract the 3 parts of the title and put them in 3 different columns
  • I extracted the labels name in one column
  • I extracted the 3 from ‘3 dirigeants’ with a regex

 

Here is a screenshot of what I currently have a my spreadsheet : 

And I would like to have all the different numbers extracted from that card in the red cell named ‘NOMBRE PARTICIPANTS’. 

Here is my setup, I hope it is easier to understand now.

Thank you Bjorn for your time !

Userlevel 7
Badge +7

Hi @Hana_ha ,

It looks like you might need a loop that iterates threw the matches and adds it to an array. In this case, I would advise you to talk to a Zapier expert or anyone else with this knowledge. Something like :

const matches = myString.matchAll(regex);
var matchExtracts = [];

for (const match of matches) {
matchExtracts.push(match);
...
}

would be needed. I don't want to direct you in any way, so feel free to try it out yourself ;) 
If you need any advise or assistance feel free to send me a message. 

Hope this helps you!

~Bjorn

Userlevel 2

Hello @ForYourIT ,

Thank you very much for your answer ! 

I tried out maaany things and thanks to you, as you pointed me in the right direction, I finally have what I want. 

I finally used the ‘Code by Zapier’ action as it was what worked best here and did a little thing in Python (after several tests and errors). But I will definitly try again with something like what you wrote so that I can know both ways to do it. 

 

This is what I have now, if it can help someone someday…

Basically, I extracted all the numbers, converted them from str to int and add these numbers together to have the result in my spreadsheet.

 

 

Once again, thank you ! :)