Skip to main content

Hey there, I have an input data that goes like this “Novermber 26th & 27th”

I am looking for a pattern where I could get the output as

1.November 26th 

1.November 27th

Is this possible with patterns? If so how.

Thanks :)

You could do this with 2 patterns. 1 to extract the month and 1 to extract the days. The only downside i see is that you get back a list so Zapier adds some commas where there shouldn’t be and as a result you may need another step to remove the commas and clean it up. 


You could also look at writing some code and doing this with a Code by Zapier step. 


 

 


@GetUWired Thanks, there is one problem. I am not seeing the output of the date pattern in other actions. This is what it shows
 

 

 

This is what the test of the action where we extract the date is like

Do you know why this is happening?

 

 


I am not sure why that is happening. Another approach would be to use code. (javascript)

 

let inputDate = inputData.dates;
output = {};

let monthMatches = inputDate.match(/January|February|March|April|May|June|July|August|September|October|November|December/g)
let dateMatches = inputDate.match(/\d{1,2}th|st|nd|rd/g)

output.month = Object.assign({},monthMatches)
output.dates = Object.assign({},dateMatches)

 


Thanks @GetUWired, that worked. Its awesome that you were able to create this code, how can I learn this so I can do such scripts on my own, this seems very interesting to me.


Hey @GetUWired, the code you sent me is not working when the input was this.

So this is the input “December (3rd-17th)”

 

 The output doesn't show “3rd”. This is the output of this action

Do you know why this happens?

 


@Fahad.S  Whoops! 
Try changing this line from 

let dateMatches = inputDate.match(/\d{1,2}th|st|nd|rd/g)

to

let dateMatches = inputDate.match(/\d{1,2}(th|st|nd|rd)/g)


As far as how to learn this, Regexr is a great tool for writing Regular Expressions: https://regexr.com/ 
The code is written in Javascript and there are a TON of resources online: https://www.freecodecamp.org/news/learn-javascript-free-js-courses-for-beginners/ 
and once you get used to the lingo Google becomes a great help!