The name 'Split' does not exist in the current context

Hey guys, relatively new to Ui path, I’m trying to split a pdf I’m working with to get content from
Total current … to usage summary. But I keep getting this error:

The name ‘Split’ does not exist in the current context

I think the issue is probably a VB error as the project is in C#. Any thoughts

@cemenike

Please try this

PdfText.Split("Total…",Stringsplitoptions.None)[0].Split("Call..",Stringsplitoptions.None)[0]

Cheers

getting a new error, ‘the name SpringSplitOptions does not exist in the current context’

HI @cemenike

You haven’t provided the proper braces. Keep braces properly.

Split((Split(testpdf,"Total Current Month Charges)(1).toString),("Call Detail Usage Summary")(0).toString.Trim)

Hope it helps!!

Didn’t work. I think in C#, I have to call the object to be split first before the function. Like a
testpdf.split, not a Split((Split(testpdf))). Not sure

Could you please provide me the proper information what to split from which text.
It makes helps us for better understanding.

@cemenike

It is stringsplitoptions…

Please check the spelling

Or use with fullnamspace System.StringSplitOptions.None

Cheers

Its basically just an invoice pdf and I’m trying to get all the information in between the words “Total current charges” to “Total Usage Summary”. Just all the information between those words

not sure I understand what you mean. Where would this go

@cemenike

Please try this

PdfText.Split("Total…",System.StringSplitOptions.None)[0].Split("Call..",System.StringSplitOptions.None)[0]

Cheers

Then use the regex expressions to extract the data between two sentences.

System.Text.RegularExpressions.Regex.Matches(yourstringinput.ToString,“((?<=Total current charges\s).*(?=\sTotal Usage Summary))”)

Hope this helps!!

1 Like

I get an “Unrecognized escape sequence error”

What is that error send me the screenshot of it. @cemenike

Have you write the regular expression in the IEnumerable datatype variable or you used the matches activity

the error is " Unrecognized escape sequence"
yeah I wrote it just how you said

the variable that i am assigning this value is a string type. Should it be an Enumerable?

@cemenike

variable must be an Enumerable.

regards

1 Like

Yes Have to change the datatype of variable to the System.Collections.Generic.IEnumerable<System.Text.RegularExpressions.Match>

still doesn’t get rid of the error. The enumerable variable is what I’m assigning to the regex statement, not my initial pdf variable right?

and @vrdabberu
I believe the issue is from the Regex string " \s". The script is fine and gives no error up until that point. Should there be a “\s” or some other way I could right that. The escape sequence in the regex is the error. Thanks for the variable correction btw

Yes @cemenike you are absolutely correct.
Change the Variable for regex statement to IEnumerable
If you can’t find how to change follow the steps :
Open the Variables panel and click on Variable type and hit on the Browser for types search IEnumerable< then click on below highlighted option as like in image.
image
Then another window is opened and search like this System.Text.RegularExpressions.Match

Click on Okay then it will change to IEnumearble

Now see the error is showing or not.

After this also the error is showing let me know

1 Like

is there anyway i can view the output of this enumerable. Just to clarify that it’s accurate