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
Solved! Go to Solution.
You can also use the expression,
B2:(.+):RB
in the Regex Tool set to Parse.
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.
Another way, this also works in the RegEx Tool set to Parse directly from your source input
(?<=\:B2\:\n)(.*)(?=\:RB\:)
@faran_ahmed Check my screenshot and attachment. Isn't the text in green in one cell [RegExOut1]? What am I missing?
@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.
Thanks, escaping punctuation is a habit 😄
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?