How to user "System Regex"

Hi everyone,
I’m trying to use “Regex” in openrpa and I’m getting a “compiler” error.
I added “System.Text.RegularExpressions” to the “Imports” section of my workflow but the error keeps showing.

Can someone help me with what I’m doing wrong?

Thanks.

Possible to share the workflow?

@UnyBots
To get the correct output, check the below methot:
Regex.Match(technician, "\d+").Value.ToString - remove the “@” and add ´.Value.ToString` in the end.

3 Likes

The @ is also in the ms documentation, not sure what that represents, but seems to work just fine without.
Match() return a Match object, not the value, and value is untyped, so you need to use Match().Value as @kowts writes. And since it’s untyped, you need to cast it to the right type. If the technician variable is a string, then you can simply use Match().Value.ToString as in @kowts’s wrote.

Lastly it’s worth mentioning, there is a Match and Matches activity to do regular expression more conveniently in a workflow.

2 Likes

That’s interesting! @Allan_Zimmermann I haven’t used the Match and Matches activity before. Thanks, I’ll definitely look into using them.
@UnyBots I recommend you to try to use @Allan activities suggestion (better and cleaner way).

@kowts thanks for your help! Works perfectly.
And @Allan_Zimmermann thanks for your explanation and indication about Match and Matches activity.
I have tested it and it works.

1 Like

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