0

I have a string in which i have unnecessary html tags(sample string is given below), i am using following regex in jquery for removing it and it is working:-

 var str = 'Dept : Dept Maths has <g class="gr_ gr_3 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar multiReplace" data-gr-id="30" id="30">a ''</g>DWE WQERT A1'' desc on school.'

 str= str.replace(/<\/?g[^>]*>/g, ""); //this is working

But i want to do it in C# code, i tried following :-

 var strRegex = Regex.Replace(str, "/<\\/?g[^>]*>/g", ""); // this is not working

But it didn't change anything.

how can i use same Regex in C# Code..any help please?

2
  • There are syntax differences, have a look here: stackoverflow.com/questions/3982608/… - then, translate your expression from JS/jQuery to C# syntax. I am afraid there is no other way. Commented Jul 29, 2019 at 13:48
  • yes will refer that, Thanks..! Commented Jul 29, 2019 at 13:57

1 Answer 1

1

In your pattern (second parameter), you don't need the delimiters or flags. Just take off the beginning "/” and ending "/g"

Sign up to request clarification or add additional context in comments.

1 Comment

Worked...Thank you..!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.