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

REGEX: Fetching multiline data into one cell between two identifiers

faran_ahmed
7 - Meteor

Simple query. I have tried multiline capture on regex101.com with below code, showing perfect result as I want but the same code isn't working in Alteryx.

 

^\s+:B2:(\n?.+\n?.+\n?.+\n?.+\n?).+\s+:RB:

 

I need everything between two identifiers :B2: to :RB: as present in the text input, parsing through a REGEX script. The number of content lines may vary from 2 to 5, that's used \n? as new lines may be optional, till :RB: is found, the trap should be stopped. below is the data, green being the content to be captured:

 

BANK LIMITED
Mackinnons Building SS Chundrigar
Road, CITY
:B2:
x0x0x0x0x0x0x0x0x0x0x0x0x0x0x
1* 2* 3* 4* 5* 6* JOHN SMITH
CAVALRY GROUND 52ND FLOOR, 39 COMMER
CIAL AREA 54600 CITY COUNTRY
:RB:SWIFT
:PD:8xxxxx159 NC-22/006/
:SRINF:/NATID/1172289-4/
/CONTINFO/92|MY@NIMBUS.DD/
:PPC:SUPP
:RGINF:/RESCNO/RTGS
E3M2xxxxxxxx471
SEQ-00001

17 REPLIES 17
PhilipMannering
16 - Nebula
16 - Nebula

Hi @faran_ahmed 

 

Please see the solution attached,

 

PhilipMannering_0-1655108390411.png

 

PhilipMannering
16 - Nebula
16 - Nebula

You can also use the expression,

 

B2:(.+):RB

 

in the Regex Tool set to Parse.

faran_ahmed
7 - Meteor

Hi Philip, thanks for reply.

 

The expression is not returning anything in Alteryx.

Moreover, I need all of the content as highlighted in green in the question, in one cell.

Matt_D
10 - Fireball

@faran_ahmed 

 

Another way, this also works in the RegEx Tool set to Parse directly from your source input

 

 

 

(?<=\:B2\:\n)(.*)(?=\:RB\:)

 

 

 

PhilipMannering
16 - Nebula
16 - Nebula

@faran_ahmed Check my screenshot and attachment. Isn't the text in green in one cell [RegExOut1]? What am I missing?

PhilipMannering
16 - Nebula
16 - Nebula

@Matt_D Nice work with the look around operators. I don't think you need to escape the colons though... I might be wrong about that.

Matt_D
10 - Fireball

Thanks, escaping punctuation is a habit 😄

binuacs
21 - Polaris

@faran_ahmed One way of dong this with the REgex_Replace method

 

binuacs_0-1655111741921.png

 

faran_ahmed
7 - Meteor

Hi, your solution is perfect. but it is concatenating everything in the data. Wanted to use only REGEX expression to work for that, if possible. as I have to apply this on a text file which contains thousand of rows and has a size around 6-8 MB.

 

specifically, when comparing the code that is working on REGEX101.com to the code in Alteryx, I think there is a problem with \n new line tags, that I am unable to understand. Otherwise it'd have been resolved. Can you please help with this?

Labels