0

I am trying to learn regex but can't figure out how the following regex, which is used to identify java block comments, works:

\/\*\_.\{-}\*\/

I know that \/\* at the beginning is for matching /* and the \*\/ at the end is for matching */.

But I can't interpret \_.\{-}. What pattern does this expression identify?

user3552506
  • 45
  • 1
  • 1
  • 6
  • regex is wrong.. It won't get the comments.. Did you test the regex? – Avinash Raj Jan 05 '16 at 07:51
  • It is a VIM regex. `\_.\{-}` matches any characters incl. a newline lazily (same as `.*?` in most engines). Note that `\_.*` matches any characters including a newline *greedily*. – Wiktor Stribiżew Jan 05 '16 at 07:51
  • @stribizhev: You say this is a VIM regex, but you marked the question as a duplicate of one about PHP/Perl/JavaScript/Python/Ruby/Java/.Net regexes . . . – ruakh Jan 05 '16 at 08:01
  • If you want, re-close with [vim search replace including newline](http://stackoverflow.com/questions/32434640/vim-search-replace-including-newline/32434899#32434899). It is still an off-topic question. [Learning Regular Expressions](http://stackoverflow.com/a/2759417/3832970). Seems like it is time to update the [Reference - What does this regex mean?](http://stackoverflow.com/questions/22937618/reference-what-does-this-regex-mean)!!! :) – Wiktor Stribiżew Jan 05 '16 at 08:02
  • i have tested it and it works – user3552506 Jan 05 '16 at 08:03
  • \* I meant to say *same as `(?s).*?` in most engines*. – Wiktor Stribiżew Jan 05 '16 at 08:20

0 Answers0