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
  • 23,232
  • 8
  • 74
  • 98
Mikołaj Waśniewski
  • 1,298
  • 14
  • 16

2 Answers2

1

Try this:

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

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

SCouto
  • 7,808
  • 5
  • 32
  • 49
1

The following regex should do the trick:

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

Visit this link for a working demo.

Tommaso Belluzzo
  • 23,232
  • 8
  • 74
  • 98