How Can I Split Non-Consistent Strings to Get the Numerical Value

I want to get the number to the right of the word “Total”. I can’t use anchors because the PDFs I’m using are inconsistent in format. I am able to find the line that contains “Total”, but I’m struggling to get the value to the right of it because of the inconsistency. For reference, here is an example of two lines that are possible:

Daily Total $228.29 $228.29
Total 335.25

Hi @mplo724

Hope this might be helpful to you!

cheers :smiley:
Happy learning :smiley:

@mplo724

Try this:

use Read PDF Text to read the text and store output in one String variable. And then try below expression to fetch the required value.

varPDFText.Substring(varPDFText.IndexOf("Total ")+"Total ".Length).split(Environment.Newline.TocharArray)(0)

Here, varPDFText variable is of type String and it’s output of your PDF text.

1 Like

hello @mplo724

try to split based of the space ,

i.e. Array1 = strvariable.split(cchar(" "))

Regards
Ajay

Hello @mplo724
Instead of splitting you can directly get the value using Regex
(?<=Total )($\d+.\d+ $\d+.\d+|\d+.+)
Just Use Matches Activity or

System.Text.RegularExpressions.Regex.Matches(TextContaingValue,"(?<=Total )($\d+.\d+ $\d+.\d+|\d+.+)")
In an Assign Activity To get the required Output
Check this Sample Workflow for better Understanding
RegexMethod.xaml (8.4 KB)

1 Like