I have invoice pdf where is seller’s and buyer’s adress and i need extract them in two different places.
The text is "…the Seller known as Donald Duck with a mailing address of Bridgeroad 5, 34234, Austria agrees to sell the following item described as Town House to a Buyer known as Daisy Duck with a mailing address of Bumbyroad 44, 23567, Austria for the purchase price of $100000 (US Dollars). "
For the seller I use “agrees” word and everuthing is OK:
Value: sellerInfo.Substring(
sellerInfo.IndexOf(“of”) + “of”.Length,
sellerInfo.IndexOf(“agrees”) - sellerInfo.IndexOf(“of”) - “of”.Length
).Trim()
But for buyer the output is blank value code is:
If(buyerInfo.Contains(“of”) And buyerInfo.Contains(“purchase”),
buyerInfo.Substring(
buyerInfo.IndexOf(“of”) + “of”.Length,
Math.Max(buyerInfo.IndexOf(“purchase”) - buyerInfo.IndexOf(“of”) - “of”.Length, 0)
).Trim(),
“”)
and if I use same code with modifying the seller adress for buyers then error is “start index cannot be larger than length of string”
Welcome to the Community!
You can use something like
This will give you Seller address:
Seller Address: textVar.Split({“Seller”},StringSplitOptions.None)(1).Split({“mailing address of”},StringSplitOptions.None)(1).Split({“agrees”},StringSplitOptions.None)(0).Trim
This will give you Buyer address:
BuyerAddress : textVar.Split({“Buyer”},StringSplitOptions.None)(1).Split({“mailing address of”},StringSplitOptions.None)(1).Split({“for the purchase”},StringSplitOptions.None)(0).Trim