Using Regular Expressions inside Invoke Code

Hey All,

I’m trying to use a simple Regex search inside an Invoke code block, but I’m not having any luck.
The trouble seems to be in importing the Systems.Text.RegularExpressions namespace inside the code block.

I managed to get it declaring a new Regex variable just fine, but then when I try and pass a value to the variable it says it doesn’t recognize it.

If anyone knows how to do this, would be much appreciated. Thanks

Example:
Dim regexp As System.Text.RegularExpressions.Regex
regexp = System.Text.RegularExpressions.Regex(“(\b\w+\b)\sreport”)
Dim m As System.Text.RegularExpressions.Match
m = regexp.Match(row(“Body”).ToString + row(“Subject”).ToString)

Returns:
Message: Error compiling code
error BC30451: ‘Regex’ is not declared. It may be inaccessible due to its protection level. At line 38
System.ArgumentException: Error compiling code
error BC30451: ‘Regex’ is not declared. It may be inaccessible due to its protection level. At line 38

As an extra - I have imported Systems.Text.RegularExpressions into the workflow that holds the invoke code block. That doesn’t appear to be it

1 Like

Could you upload your workflow. I’d like to see what you did.

Eventually found a solution - Have to import a blank regex and match variable into the Invoke Code Block as arguments. This apparently brings the namespace in with them, and can then be used.