String Function


How to find a specific word which are extracted from a pdf using string ?
For Ex i have extracted a set of data in that i need to find the word ‘Due’ and extract the amount next to it.
Due $50

Output should be $50.

1 Like

Try the following regex agains the string : (?<=Due )(\$\d*)
The output will be the 1st capturing group.

Also see for testing.

hello @Robotics

variable2=“Due $50”


1 Like

Hi @Robotics,
The perfect approach for this is use of Regex.
For an example:
regex101: build, test, and debug regex - from here you can catch “Due” word and use it
regex101: build, test, and debug regex - from here you can get amount for the same string.

use split like this buddy @Robotics
Once you get the text from pdf with output variable named out_text_pdf try like this buddy

  1. First split each line into arrays like
    out_split_array = out_text_pdf.Split(Environment.Newline.ToArray(),StringSplitOptions.RemoveEmptyEntries)
  2. Then use a for each loop to iterate through each line with out_text_pdf asinput to the for each loop and change the type argument as string
  3. use a if condition within the for each loop like this
    if this condition is passed go for then part in if condition like
    out_amount_value = item.split(“Due”)(0).ToString.Trim

This would give $50 alone buddy

Thats all you are done

Cheers @Robotics

Did that work buddy @Robotics

@ Palaniyappan : I am getting the below said error

item.split(“Due”)(0).ToString.Trim - ‘Compiler Error encountered processing expression. Option StrictOn disallows late binding’

1 Like

Fine get like this buddy @Robotics

Were you able to get now buddy

No. After reading the pdf in Assign i have given the below line

  1. out_text_pdf.Split(Environment.Newline.ToArray(),StringSplitOptions.RemoveEmptyEntries)
  2. In for each in IF condition given as "item.ToString.Contains(“Due”)
  3. In Then part given as
  4. Trying to display out_amount_value in msg box
  5. Msg box not shown. No error aswell

Buddy kindly use a message box before splitting and after reading pdf inorder to check whether pdf is first read or not, as you are going good so far, lets make sure that
we get data from pdf buddy @Robotics

as @RobertD this will work for you - simple and easy :slight_smile:

Sample - RegexSample.xaml (6.6 KB)


@Palaniyappan. I am able to read the contents from pdf in msg box.
I guess this does not work - out_text_pdf.Substring(“Due”.Length)
I am assigning this to a variable and trying to print in msg box which returns
the entire content which is present in pdf. Attached the sample pdf.

wordpress.pdf (42.6 KB)