Regex Or String manipulation

Hi All,

I am reading pdfs, and using Regex to get the numbers i need. I get my data in an array, like below:

Index0 = 424.69 2 831.26 3 255.95

index1 = 1 954.64 13 236.64 15 191.28

index2 = 147.30 981.96 1 129.26

index3 = 111.20 741.31 852.51

etc…

The above numbers, are totals, I need to get each total number eg:

1 954.64.

I have tried splitting by white space (.Split(" "c)) but then if a number is 1 950.57 it will take it as two separate numbers like this (1 and 950.57).

Please help.

Becoz it has space, try to split by(white space after decimal digit)

Thanks @KarthikBallary, do you have an example of how i can archive that?

I have written the below regular expression pattern but not sure if it will work in all cases, However, it works for the current set of numbers, just that i am not really not sure how robust is it.

\d{1}\s\d*.\d{2}|\d{2}\s\d*.\d{2}|\d*.\d{2}

@SenzoD

Since, there’s nothing that can seperate those numbers, i have an idea…

You split by space, but don’t split if there’s a space after only one digit.

For example :

2 999.3 no split

344 334 split

Got the idea ?

2 Likes

Try using regex grouping. that will give you the results directly and you dont need to use string manipulation again.
Is it possible to post the complete text that need to be extracted?

2 Likes