0

I've got an expression like this:

/* pierwszy */  using System;/* drugi */

and I want to match all comments in this line.

But this regex:

\/\*(.*)\*\/

is unfortunately not working, because it matches that:

pierwszy */  using System;/* drugi

So, as you can see, it matches the whole expression. Anybody knows how to write a regex to match subgroups, not the whole expression?

Tommaso Belluzzo
  • 22,356
  • 7
  • 68
  • 95

2 Answers2

1

Try this:

\/\*([\w|\s]*)\*\/

It will match any word or space character between /* and */

SCouto
  • 7,371
  • 4
  • 33
  • 47
1

The following regex should do the trick:

\/\*\s*([^\s]+)\s*\*\/

Visit this link for a working demo.

Tommaso Belluzzo
  • 22,356
  • 7
  • 68
  • 95