Please use an assign activity, str_buyer_address= System.Text.RegularExpressions.regex.Match(your_PDF_Text,"(?<=Buyer Address:)[\s\S]*(?=Seller Address:)").ToString
It will return all the text in between “Buyer Address:” and “Seller Address:” as string.
Ok I am using this expression in a different workflow, now it says “Regex is not declared. It may be inaccessible due to its protection level”. How do I resolve this?
18.4.0+Branch.master.Sha.b805b316b1c47ae06c0fe7e619b9c9f96e9e774c
Source: Assign
Message: Specified argument was out of the range of valid values.
Parameter name: i
Exception Type: System.ArgumentOutOfRangeException
An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: i
at System.Text.RegularExpressions.MatchCollection.get_Item(Int32 i)
at lambda_method(Closure , ActivityContext )
at Microsoft.VisualBasic.Activities.VisualBasicValue`1.Execute(CodeActivityContext context)
at System.Activities.CodeActivity`1.InternalExecuteInResolutionContext(CodeActivityContext context)
at System.Activities.Runtime.ActivityExecutor.ExecuteInResolutionContext[T](ActivityInstance parentInstance, Activity`1 expressionActivity)
at System.Activities.InArgument`1.TryPopulateValue(LocationEnvironment targetEnvironment, ActivityInstance activityInstance, ActivityExecutor executor)
at System.Activities.RuntimeArgument.TryPopulateValue(LocationEnvironment targetEnvironment, ActivityInstance targetActivityInstance, ActivityExecutor executor, Object argumentValueOverride, Location resultLocation, Boolean skipFastPath)
at System.Activities.ActivityInstance.InternalTryPopulateArgumentValueOrScheduleExpression(RuntimeArgument argument, Int32 nextArgumentIndex, ActivityExecutor executor, IDictionary`2 argumentValueOverrides, Location resultLocation, Boolean isDynamicUpdate)
at System.Activities.ActivityInstance.ResolveArguments(ActivityExecutor executor, IDictionary`2 argumentValueOverrides, Location resultLocation, Int32 startIndex)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)
This happens when I want to retrieve the string from the MatchCollection… I am sure that the text file I am searching contains the start delimiter, end delimiter and some text in between. What might be causing this? Yesterday I tried it and it worked fine, I only encountered this today
First activity: Regex.Matches(text,“Start text (.*) End Text”)
Second activity: x(0).Groups(1).ToString
Put your full string there and the pattern and you can confirm whether the pattern works or not
In case things in your output string changed (like space between words/positions) the regex will fail. So you need to design regex in such a way that it can handle all possible shifts in the string as well (at least all expected based on tests)