cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert a text in a Datapill

tco
Deputy Chef I
Deputy Chef I

Hello the Community,

Happy Holidays !

Maybe a simple question but I am stuck...

I have the following response from one of my step of my recipe : 

"{"text-Platinum","choices":[{"text":"\n\n1. MED001 - Digital Stethoscope - $99.99\n2. MED002 - Blood Pressure Monitor - $59.99\n3. MED003 - Disposable Surgical Caps - $9.99","index":0,"logprobs":null}}

What will you recommend to extract the following :

ParNum : MED001, MED002, MED003

Description : Digital Stethoscope, Blood Pressure Monitor, Disposable Surgical Caps

Price : $99.99, $99.99,$9.99

and be able to have it in a DataPill I can use in the following steps of my recipe.

Thanks in advance for your help,

Happy New year,

Thierry

 

1 ACCEPTED SOLUTION

dcornwell
Deputy Chef III
Deputy Chef III

Hi Thierry,

Using my new best friend (ChatGPT) it came up with a RegEx "\bMED\w+"
which can extract the values starting with MED from the text.  Having not used RegEx in Workato I had a quick try by following the Workato  documentation and it didn't work.

I'm out of time to experiment today but the other approach I would take with that particular text is to parse it as JSON (or just deal with it as a string) and split it using the newline (\n), then iterate over it and look for the location of ".M" then use that to get a substring of the MED value.  Obviously there's some nuance in how to do that but that's a general approach.

Having said that, the best bet might be to get someone who knows RegEx to advise how to implement it in Workato using that expression "\bMED\w+".

 

Regards, David

 

View solution in original post

3 REPLIES 3

dcornwell
Deputy Chef III
Deputy Chef III

Hi Thierry,

Using my new best friend (ChatGPT) it came up with a RegEx "\bMED\w+"
which can extract the values starting with MED from the text.  Having not used RegEx in Workato I had a quick try by following the Workato  documentation and it didn't work.

I'm out of time to experiment today but the other approach I would take with that particular text is to parse it as JSON (or just deal with it as a string) and split it using the newline (\n), then iterate over it and look for the location of ".M" then use that to get a substring of the MED value.  Obviously there's some nuance in how to do that but that's a general approach.

Having said that, the best bet might be to get someone who knows RegEx to advise how to implement it in Workato using that expression "\bMED\w+".

 

Regards, David

 

arturgm
Deputy Chef I
Deputy Chef I

Just to add 2 cents, this is also great for fiddling around with regex: https://regexr.com/

meghan-legaspi
Community Manager
Community Manager

Hey @tco! Did either of the suggestions provided work for you? Would love to get an update if you have one!