Help with .split of a string

Hi there,

I have this string:
image

I need to split it into different sections.

The first part is to split (1), (904494) & (203139) into each of their own.

Now comes the tricky part… Then I need to split (Reline Acrylic Base), (X1),(15.00 €) and (15.00 €)
And same on next line I need (Adhesive per unit) (X2) (6.00 €), (12.00 €)

Can anyone help me with this, I have been trying all sorts of ways, but did not manage to get any good results… I always end up with it all mixed up :frowning:

Thanks in advance, and best Regards,
Martin

@MartinJA
Write regex for this to extract the data separately instead of split.

@rlgandu

Can you help me with a pattern? I suck at regex :stuck_out_tongue:

Thanks in advance

Hi @MartinJA

Since you have already written regex to extract the line you can again write regex to extract the sub items.

Share the input and expected output separately, so that I can help you with regex.

Regards

@MartinJA

Please send the input text in notepad

Notepad.txt (14.7 KB)
Here you go; wanted format is a explained in question :slight_smile:

Oh, I can also give the already used RegEx Pattern if that would help;
(?<=\n|^)\s*(\d+)\s+(\d+)\s+\d+\s+([\s\S]?)(?=Case Total:\s\d+.\d{2} €\s*\n)

@MartinJA

[A-Z]+.*(?=\s[A-Z]+\d+\.?\d*\s\d+\.\d+\s*\€\s\d+)-->Reline Acrylic Base
[A-Z]+\d+\.?\d*(?=\s\d+\.\d+\s*\€\s\d+)-->X1
\d+\.\d+\s*\€\s(?=\d+\.)-->(15.00 €)
(?<=\€\s)\d+\.\d+\s*\€\s-->(15.00 €)

I hope this helps you.If not this works please update me.

1 Like

@rlgandu

How do I use this regex on my already “regex’ed” text?

When I try using the find matching pattern acivity, it says that it needs to be a string and not a IEnumberable(Of Match).

And when I do it in a foreach it gives same error just with match instead of IEnumberable…

Thanks in advance :smiley:

@MartinJA

Use For each FirstMatches and currentText -->IEnumberable(Of Match)1.
use For each currentText and currentText1–>IEnumberable(Of Match)2.

Please share the screenshot of what you got the error

@rlgandu

This is what I got so far (I’m only testing retrieving the data from the PDF…