cancel
Showing results for 
Search instead for 
Did you mean: 

C# Regex not working on Code Stage

Anonymous
Not applicable
Hi guys,

I have a code stage that is not working on BP. Basically is not matching my string.

The code is 


//Match m = Regex.Match(Target_String,Regex_Pattern, RegexOptions.IgnoreCase);
var m = Regex.Match(Target_String, Regex_Pattern);
try { if (m.Success)
{ Regex_Match = true; }
Regex_Match = false;}
catch (Exception)
{ Regex_Match = false;}

It runs perfectly on Visual Studio but not in BP.
Inputs : Target String and Regex_Pattern, both are text
output is Regex_Match which is boolean , so flag

I am doing a loop on a collection of credentials. When I check for chn[0-9][0-9][0-9]+ nothing is found./

The VB code is working perfectly, but i need it on C# code stage

Dim R as New Regex(Regex_Pattern, RegexOptions.SingleLine)
Dim M as Match = R.Match(Target_String)
Regex_Match = M IsNot Nothing AndAlso M.Success

------------------------------
Cohen
RPA Developer

Romania
------------------------------
1 REPLY 1

Anonymous
Not applicable
The answer was to shorten the code and to make a syntactic sugar code:

var m = Regex.Match(Target_String, Regex_Pattern);
Regex_Match = m.Success;

------------------------------
Cohen
RPA Developer

Romania
------------------------------