Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

This question got me thinking in a regex for matching javadoc comments that include some specified text.

For example, finding all javadoc fragments that include @deprecated:

/**
* Method1
* .....
* @deprecated
* @return
*/

I manage to get to the expression /**.*?@deprecated.*?*/ but this fails in some cases like:

/**
* Method1
* .....
* @return
*/
public int Method1() { } 

// this method should be @deprecated
public void Method2() { }    

/**
* Method3
* .....
* @return
*/
public int Method3() { } 

where it matches all the code from the 1st javadoc fragment until the 3rd javadoc fragment.

Can someone give a regex for this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
138 views
Welcome To Ask or Share your Answers For Others

1 Answer

Try this one :

/**([^*]|*(?!/))*?@deprecated.*?*/

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...