Regex did not get every item from the string

I need help on a regex pattern.

I have this line:

test = "/*testing 1*/Name: /*Testing 2*/ My Name" 

I need to delete each /**contents **/of the line.

I use regex to do filtering with the following code:

Regex rx = new Regex(@"/\*[^>]+\*/");
Template = rx.Replace(Template, match => { return String.Empty; });

but the result that I get is only "My name" , the expected result is "Name: my name" .

+4
source share
1 answer

Change the regex to /\*[^>]+?\*/.

? + , */ . , /* ... */, regex .

+4

All Articles