SO here is my problem. I need to go through a pretty long java code and find comments with a particular word or statement. If it is present I need to copy part of the following code into a text file. For eg. if the word is "cat"
/**
*this code is related to the cat
*/
public static int a = 5;
public static String b = "abcd";
I need the output text file to have the first string after the comment with the word "cat" so here it would be "abcd". I guess I could parse the whole code as a text file and look for comments but is there a faster and more intelligent way?
edit: I tried doing a grep and it does not work since the first occurrence of String is at variable distances and increasing the number of lines to take sometimes includes the next comment too.