Best answer

Formatter Help: Parse out number string

  • 30 July 2022
  • 1 reply
  • 202 views

Hello,

I need to parse out a string of numbers in a folder name. The format is always going to be “LastName_FirstName_00_00_0000_foldertype” with the 00_00_0000 being Month_Day_Year - the part I need separated. I feel like it should be doable because the numbers needed are the only numbers in the string but I just can’t seem to figure it out. Once it is extracted, I also need to format it to a standard date format of 00/00/0000

 

icon

Best answer by Danvers 1 August 2022, 12:25

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.

1 reply

Userlevel 7
Badge +12

Hi @nps_clt!

There are a couple of ways that you can do this:

  1. Use regex to get the numbers from the string. This will be more flexible to changes in the rest of the text (eg if there is more than one first name), but it will also require an additional Formatter step to change the format of the number to the 00/00/0000 that you need. Obviously, this also requires a knowledge of how regex works (here’s a how to guide)
  2. Use a split text step. This requires less technical knowledge and means that you wont need to add an additional date format step BUT it will go wrong if there are a different number of underscores in the text. For example if you have one input that’s firstname_middlename_lastname_00_00_0000_foldertype, that will break the subsequent steps. 

 

For the second option, add a Formatter by Zapier step in your Zap and:

  1. Select Text for the Event
  2. Select Split Text for transform
  3. Type an underscore in the transform field
  4. For the Segment index, select ‘All (as separate fields)’

That will give you each piece of text in between the underscores as a separate field that you can use in a later step of your Zap.

 

Then, in your later steps, add each number from the dropdown choice and type a ‘/’ in between each one to create the date format that you need

(here’s a gif showing how I entered that in the field)

 

That’s quite a lot of info, so let me know if you have any questions! And let me know how you get on - I’d love to know if this helps!