I am currently doing comment analysis with some Java code and needed to do the following opperation:
comment = comment.replaceAll("/**", "");
But I am meet with this Exception:
Exception in thread "main" java.util.regex.PatternSyntaxException: Dangling meta character '*' near index 2
/**
^
at java.util.regex.Pattern.error(Unknown Source)
at java.util.regex.Pattern.sequence(Unknown Source)
at java.util.regex.Pattern.expr(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at java.util.regex.Pattern.<init>(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at java.lang.String.replaceAll(Unknown Source)
at commentCoupler.coupler.commentCriteriaForfilled(coupler.java:234)
at commentCoupler.coupler.analyze(coupler.java:64)
at commentCoupler.coupler.recursiveCoupler(coupler.java:27)
at commentCoupler.coupler.recursiveCoupler(coupler.java:22)
at commentCoupler.coupler.recursiveCoupler(coupler.java:22)
at commentCoupler.main.main(main.java:16)
Edit: The exception also occurs when I do
comment = comment.replaceAll("**/", "");
and
comment = comment.replaceAll("*/", "");
Do anyone know why this happens and do anyone have a workaround?