Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Multi field Regex

Istwineres
8 - Asteroid

Hi, I'm looking for a regex expression that I can use into multi field formula tool to extract the text. The empty/template string looks like this:

{"blocks":[{"key":"14qa","text":"","type":"unstyled","depth":0,"inlineStyleRanges":[],"entityRanges":[],"data":{}}],"entityMap":{}}

If there is text, in this case to be extracted, it looks like this:

{"blocks":[{"key":"c1247","text":"Requires repetitive human interaction to log in to different systems and collect data in a spreadsheet.","type":"unstyled","depth":0,"inlineStyleRanges":[],"entityRanges":[],"data":{}}],"entityMap":{}}

7 REPLIES 7
TomWelgemoed
12 - Quasar

Hi @Istwineres ,

 

This is JSON text - don't you just want to use the JSON Parse tool?

 

TomWelgemoed_0-1614260496773.png

Regards,

Tom

ChrisTX
15 - Aurora

As mentioned, the JSON Parse tool is the easiest option.

 

If you want to use RegEx in Parse mode, try this expression:  (.*)("text":")(.*)(","type")(.*)

 

Screenshot 2021-02-25 074433.png

 

Chris

Istwineres
8 - Asteroid

I know it is JSON text, this is a partial result from a RESTful API get but I get this error " JSON Parse (39) Error message: The document is empty. at character position: 0". Moreover I need to apply to mulltiple fields

TomWelgemoed
12 - Quasar

Thanks @Istwineres,

 

That context helps. Did you try @ChrisTX 's suggestion?

 

If that doesn't do it, would you mind to submit a sample file so I can try & help? I'm thinking a macro may be an option too.

Istwineres
8 - Asteroid

I've got this part I'm trying to use in a multi field formula to avoid 8 parse regex tools

ChrisTX
15 - Aurora

Try the Multi Field Formula tool with this function:

 

REGEX_Replace([_CurrentField_], '(.*)("text":")(.*)(","type")(.*)', "$3")

 

Screenshot 2021-02-25 082941.png

 

Chris

Istwineres
8 - Asteroid

Many thanks! I missed the "$3" part of the replace in Regex formula

Labels