Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

Extract multiple lines text using Regex

Okeh
6 - Meteoroid

I need to extract multiple lines from a multiple line text:

 

Text Body:

[CASE CLOSURE]   EMEA Technical Service Centre

 

[PROBLEM OVERVIEW]

This is the problem portion of the message

in multiple lines description

 

[SUMMARY OF WORK]

This is the work being done for the ticket in

multiple lines description

 

[REASON FOR CLOSURE]

No trouble found

 

[ROOT CAUSE]

No trouble found

 

 

I need to make out new columns out of it and each column needs to split the Problem Overview, SUMMARY OF WORK, REASON FOR CLOSURE, ROOT CAUSE.

So mainly anything comes between brackets are the new header and I should extract the text comes afterward in multiple lines and stop at each "[".

 

I have been looking around, but couldn't find myself doing well with Regex.

 

9 REPLIES 9
ponraj
13 - Pulsar

possible to share sample data ? 

Okeh
6 - Meteoroid

The text body I shared up is the multiple lines text message. Those are being send in Emails notification. So I want to split the contents of the message based on the headers I mentioned. The text body already contains these headers in brackets. But now I need to parse them into columns

afv2688
16 - Nebula
16 - Nebula

Hello @Okeh ,

 

Something like this?

 

Untitled.png

Okeh
6 - Meteoroid

Nice Solution. But the problem that the contents are not always in the same order. So instead of assuming that PROBLEM OVERVIEW always comes after CASE CLOSURE. I need to select everything comes after CASE CLOSURE till the next open brackets "[".

Also it seams it doesn't work with new lines. Do I need to add cleansing first?

esar
8 - Asteroid

Hi @Okeh,

 

1. parse i.e. case number and use is as an ID of the row.

2. Tokenize and "Split to Rows" with REGEX message by using brackets and text between closing and opening.

3. Parse header and message to separate columns.

3. Cross Tab rows and use generated ID for grouping.

 

Sections do not have to be in the same order in this method.

You may clean linebreaks if necessary.

afv2688
16 - Nebula
16 - Nebula

This maybe work for you

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Regards

 

 

Okeh
6 - Meteoroid

Thanks so much. The parsing solution was a better match.

Do you know if I have multiple matches in the same field, how can I stop at first match only starting from top using the regex example you attached?

afv2688
16 - Nebula
16 - Nebula

Hi @Okeh 

 

If there are mutiple matches you can modify the crosstab tool to take only the first example (on the last box of the configuration window) instead of concatenating them.

 

Regards

Okeh
6 - Meteoroid

I believe the first Example with Regex_replace module is more serving my goal. But with that, I need to know how to stop Regex_Replace just at the first match?

Labels