javascript - Get Equivalent regex in C# for chopping off leading and trailing substring -


javascript :

 "[***smart tag ***]".replace(/^(\[\*\*\*)|(\*\*\*\])$/g, '');  //  getting expected output "smart tag" 

in c#.net

 var inputstring = "[***smart tag ***]";   string pattern = @"/^(\[\*\*\*)|(\*\*\*\])$/";   regex regexsmartag = new regex(pattern); //not working  var output = regexsmartag.replace(inputstring,"");   //expected out put : smart tag //current output : "[***smart tag ***]"; 

help me trim off characters chracters input string desired output.

string pattern = @"^(\[\*\*\*)|(\*\*\*\])$";   

you dont need // delimiters here.you can rewrite ur regex as

string pattern = @"^(\[\*{3})|(\*{3}\])$";  

Comments