To extract values between two strings of text

studio

#1

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…


#2

you can use for each activity to go through list.


#3

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


#4

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)


#5

@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.

#6

thanks… could you please share a XAML file?


#7

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


#8

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.


#9

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?


#10

any other way??


#11

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


#12

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


#13


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


#14

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


#15

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