To extract each number given after a set string inside an extract from PDF

Hi,

I have an extract from read PDF where it is put into a single string variable type for example it reads like this

21x 3. Soft drink/ Bottled Water
21x 2. Nespresso Coffee Station
21x 4. Afternoon Tea Pack ( min 4 ppl ) - Chefs selection of sweet and
savoury muffins or slices
10x 1. Chips/ Nuts bag
of different flavours
21x 3. Morning Tea Pack ( min 4 ppl )
1x 8a. Standard White wine
1x 9a. Standard Red wine

What I am trying to do here is to be able to extract the number after the x and before the . part of each item inside the string

So the output extracted for each item would be as follows
3
2
4
1
3
8a
9a

What would be the suitable approach to go about this?

@ciaramkm - You can try the below regex pattern…

(?<=x ).+(?=\.)

Or

(?<=x )\S+(?=\.) - If you any other period in the sentence..

Hi. Thank you for the suggestion, I attempted it with the below workflow but it kept returning a blank output

@ciaramkm - since you are looking to return multiple items, you have to use Matches…Not Match…

give me a min…i will show you…

Update: Please check this…

Here StrMatches is of variable type: Match Collection(system.text.regularexpressions.MatchCollection)

Write Line(Without Looping) = String.join(vbcr,StrMatches.cast( of Match).Select(function(x) x.ToString))

Here is the XAML:
Regex_CM.xaml (7.0 KB)

Brilliant - thanks so much for your help!

1 Like

Hi again…have a similar question except this time I am looking to extract the numbers before each x of each item. I would like to do the similar regex as used for the above. The closest I was able to get it would only get one digit number at a time. What would be the best suggestion to use?

21x 3. Soft drink/ Bottled Water
21x 2. Nespresso Coffee Station
21x 4. Afternoon Tea Pack ( min 4 ppl ) - Chefs selection of sweet and
savoury muffins or slices
10x 1. Chips/ Nuts bag
of different flavours
21x 3. Morning Tea Pack ( min 4 ppl )
1x 8a. Standard White wine
1x 9a. Standard Red wine

Output I would be looking for is
21
21
21
10
21
1
1

@ciaramkm - Here you go…

Ah thank you, that link is helpful - will be bookmarking it!

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