To extract values between two strings of text

how to extract data between two different strings of text file if text file is stored in list of UI path. As line item is required to be extracted…

you can use for each activity to go through list.

@mhk15
Can you please send a xaml with the input data and explain what you really looking as output?

1

this pdf is converted into text then I have applied string operation to extract data that starts with " Pos. Art.no. Quantity Description Unit price Total EUR" and ends with “Goods supplied in accordance with our General Conditions for the Sale and Supply of goods as published on”. I have shared my XAML file also. but I’m not able to extract that particular portion… please help me to pocess21.2(list items).xaml (6.9 KB)

@mhk15

  1. Retrieve the data from pdf file. This will be assigned to a string variable strContent
  2. Find index of the text from where the data need to be copied. Consider your search text is saved in a string variable strStartSearchText and index is stored in an integer variable intStartIndex
    intStartIndex = strContent.IndexOf(strStartSearchText)
  3. Find index of the text where the data copying should be stopped. Consider your search text is saved in a string variable strEndSearchText and index is stored in an integer variable intEndIndex
    intEndIndex = strContent.IndexOf(strEndSearchText)
  4. Find length of startindex to endindex and assign it to an int variable, intLength
    intLength = intEndIndex - intStartIndex + 1
  5. Find substring of the text. Consider your resultant data will be assigned to a string variable strResult and it contains the entire table data
    strResult = strContent.Substring(intStartIndex, intLength)
  6. Now generate a regex template to match every line items.
  7. Use “Matches” activity to retrieve all the line items.
  8. Loop through the result, use string manipulation methods to retrieve column data.
3 Likes

thanks… could you please share a XAML file?

finding this error. Not able to extract even. please provide m XAML file if possible

You might have created two variables with same name but with different scopes and you are assigning value into one and using the other somewhere else.

When you have your text extracted, you can find the bit you want with the following regex expression inside the “Matches” action.

“(?<=” + labelBefore + “)” + “(.*)” + “(?=” + labelAfter + “)”

Where the labelBefore is a string preceeding the wanted bit and the labelAfter is a string following the wanted bit.

Is this helpful?

2 Likes

any other way??

But I have stored my file in an array of strings but I am not able to find index of that particular string.

1 Like

The search string should exactly match the content in the array.


how to find the index within this text file…???strline contains all the text file path…

Since not able to find index of string present in text file so not able to extract the required text also. could u please share any of the XAML file which will be doing the same task. index of fixed character are easily extracted. But here we have to access a text file and find string in that text file

try using instr method
In assign activity
index storing variable =instr(Bigger string variable, searching variable)
this will return searching variable index number in the Bigger string

I am trying same but I got error as “StrIndex cannot be less than zero”…
I have posted on exact question on following link. Please check it.

Can you please provide your workflow and input file?

Untitled

I want to fetch the data “100$”

Untitled

So I developed above logic.

Word_Screenshot

I got above result. But I just want 100$.

@Jayesh_678
Use Matches activity, and set below properties-
Input - The extracted data from pdf
pattern - Capture
From the result, take first record.

1 Like