我写了一个正则表达式,它将用偶数个斜杠替换奇数个斜杠,而使偶数个斜杠完好无损。但由于某些原因,我得到一个错误:我的正则表达式有什么问题吗?
int matchFlags = StringUtil.MATCH_SINGLELINE;
int replaceFlags = StringUtil.REPLACE_ALL + StringUtil.REPLACE_BACKREFERENCES;
String pattern = "(?<!/)/(//)*(?!/)"; //replace odd # of slashes only.
String replace = "$0$0";
RE re = new RE(pattern, matchFlags);
result= re.subst(result, replace, replaceFlags);
这是异常:
Exception in thread "main" org.apache.regexp.RESyntaxException: Syntax error: Missing operand to closure
请不要在你的问题中使用HTML。改为使用[Markdown](http://stackoverflow.com/editing-help)。 – adarshr 2012-02-22 09:42:17
好的谢谢你的提示 – Wael 2012-02-22 09:45:38
'“奇/斜杠///替换// // ////".replaceAll("(? beerbajay 2012-02-22 10:03:20