Help with compiler error thrown from using currentMatch in Regex

While working on a windows legacy project in studio, I got the compiler error thrown from working with Regex:
The assign where the error was thrown:
image

The error:
image

the regex: System.Text.RegularExpressions.Regex.Match(currentMatch.ToString,β€œ(([0-9]+[A-Z]+)|([A-Z]+[0-9]+)|([0-9]+))”).Value

I checked my import and I do have the System.Text.RegularExpression in my namespace.

I have applied the solution I found on the UiPath forum for similar issue, but It did not work.
Help will be appreciated.

@Yomi_Oluwadara,

It’s issue of your variable you are trying to find matches from. It’s not issue of Regex namespace.

Check if the currentMatch variable is available in the scope where you are using this code.

Thanks,
Ashok :slight_smile:

it looks like you had configured the loop var to currentItem but are using currentMatch

UPD1 - Visualization Screenshot added

1 Like

@Yomi_Oluwadara , @ppr is right, you had used the wrong variable, pls replace the currentMatch with currentItem

Thanks @ppr and @ashokkarale , that resolved that issue, however, another one popped up it has to do with Last from this expression

System.Text.RegularExpressions.Regex.Matches(currentItem.ToString,"([A-Z]+([0-9]+)?)").Last.ToString

image

give a try at

System.Text.RegularExpressions.Regex.Matches(currentItem.ToString,"([A-Z]+([0-9]+)?)").Cast(of Match).Last().ToString

@ppr
This is also throwing that error due to Last
System.Text.RegularExpressions.Regex.Matches(currentItem.ToString,β€œ(?<=([A-Z]+([0-9]+)?)\s+)\d+”).Last.ToString

we inserted Cast(of Match)
grafik

and did not use Last without the brackets
grafik

1 Like

Thanks @ppr and @mukesh.singh , I have noticed there is a huge diff in bahavior between versions of studio

@Yomi_Oluwadara
It looks like it is now working, So close the topic by marking the solving post

not really, as most of the things are coming from the .Net Plattform

using the Match Activity returns an IEnumerable(Of Match)

  • we do not the cast for using the Last Operator

using the Regex.Matches returns the MatchCollection

  • in Legacy we use the cast(Of Match)
  • in Windows we can maybe omit

We use the Last Operator always with the Brackets

UPD1 - spelling and styles

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.