How to get specific text from an string

I am struggling to get a specific text from a string structured like below:

"[ Code                               Type                                 Max Price    Occupant
126ABC                          blah  1                               	625,000.00 smith, joe (12345)
127ABC                          blah 2                               	625,000.00 taylor, test (56789)
128B/2228                     	blah 3		                         	420,000.00
128ABC                          blah 3	                         		750,000.00 michael, wills (87609)
129ABC                          blah 4				                    650,000.00 ralf, joane (23780)
12ABC                           blah 5		                           	525,000.00 abdul, kareem (26790)
130ABC                          blah 6				                   	650,000.00 jimmy, sampras (13895)
131ABC                          blah 7				                    650,000.00 lendell, watts (23349)
132SBC                          blah 8				                    650,000.00 birt, hinda (23098)]"

I want to get all the codes (i.e 126ABC,127ABC etc) on the left and put it in an structured format like an array. Can someone please assist?


I have used Regex for the text shown above.

I have splitted the text and saved into an array every string that starts after the (number series) section.

Then I have looped through the array and got the code by doing trimstart and splitting the text by space.
I supposed that the code should be with length >2.

The results of the log messages are:


The first one cant be found with this logic but it can be found inside another assign activity outside of For each by using (text.Substring(text.IndexOf(“Occupant”)+“Occupant”.Length,100)).TrimStart.Split(" "c)(0)
and storing it into a separate variable.

128ABC cannot be found with regex even if it is inside the text because before it there is no sequence (number series) like for the other rows. It is a mistake or it can happen for other rows too?

Hi @sacad

You can trythis regex


@sacad - Another option…Note: Choose “Multiline” in the regexoption

Hopes this helps…

1 Like

Thanks it worked for most cases, however if the text on the left contains string like A.22IVH
this fails.
Can you assist? not too familiar with regular expressions

@sacad - Please check the updated Regex here…