Extracting data from an Array of Strings

Hi all, I get some data like below and put it in to a string

License holder Assad
Licensed Address Erdington UK
Reference Number 054504
Expiry Date 20/04/2019
(deliberate empty line for my example)
Other licence number 2644646

I then use this in an assign ‘ExtractedData.Split(Environment.NewLine.ToArray,StringSplitOptions.RemoveEmptyEntries)’
to put it in to an array of strings

If I then want the ‘Other licence number’ I would use ‘ExtractedDataArray(4).ToString’ in an assign to return ‘Other licence number 2644646’ I could then use split by a " " delimiter to isolate the number of 2644646

I recognise referencing the row of array would be problematic if position changes like in the example below

License holder Smith
Licensed Address Erdington UK
Reference Number 784746
Expiry Date 20/07/2019
Over 65? Yes
Other licence number 2644646

‘Other licence number’ is now row 5.

How would I overcome this? I’m guessing I would need to write sort some of ‘expression’ that gets the ‘row’ with the text ‘Other licence number’ in but I don’t know how to do this (or use a different method if that is better)

Thanks in advance,

Do you need to split the Array or?
If you have the whole thing as 1 string i would just use Matches Activity (Using Regex) :

Other licence number(.*)

Then select 1st group.

I can make you an example XAML if you want

Hi @srdjan.suc, no it can be in whatever format you think is best and that would be amazing if you don’t mind :slight_smile: Thank you so much

RegexforForum.xaml (5.1 KB)


Regex is such a powerful tool for us RPA developers, I suggest learning this topic when you have the time

Thank you :slight_smile:
Makes sense (the regex builder)

Please can I ask what RegexResult(0).Groups(1).Value is referencing (why do you have you use .groups(1).value?

I’m guessing that if the data didn’t have any structured information to reference against (i.e it doesn’t have ‘field names’) that it would be really difficult to get the information you want because it would be different for every customer?

Erdington UK
(deliberate empty line for my example)

Thanks again,

When you use Matches activities it returns Array of results, hence the RegexResult(0)

When you try this regex that I’ve built you select the whole :
Other licence number 2644646

And the first capturing group is

That is why I use .Groups(1).

I’m sure that you can make regex just for the numbers but this one was just quick thought.

For the last example, yes it would be difficult to select the exact number that you want but not impossible (Remember regex is good when there is some type of rules). So if your desired number was always in the last row you might use something like this :

(\d{6})$ then select RegexResult(1) (because it selects the 0 group as well the 054504), it depends on the pattern

1 Like

That makes sense, thank you for being so helpful :slight_smile:

1 Like

No problem :slight_smile:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.