groovy or java: how to retrieve a block of comments using regex from /** ***/? -
this might piece of cake java experts. please me out:
i have block of comments in program this:
/********* block of comments - line 1 line 2 ..... ***/
how retrieve "block of comments" using regex?
thanks.
something should do:
string str = "some text\n"+ "/*********\n" + "block of comments - line 1\n" + "line 2\n"+ "....\n" + "***/\n" + "some more text"; pattern p = pattern.compile("/\\*+(.*?)\\*+/", pattern.dotall); matcher m = p.matcher(str); if (m.find()) system.out.println(m.group(1));
(dotall
says .
in pattern should match new-line characters) prints:
block of comments - line 1 line 2 ....
Comments
Post a Comment