Java 正则表达式中是否有模式可以匹配;同时跳过&喜欢文字吗?
最佳答案
您需要正则表达式,例如:(?<!&);
Demo and Exaplaination
正则表达式的含义:查找前面没有&的;
代码示例:
Pattern pattern = Pattern.compile("(?<!&);");
Matcher matcher = pattern.matcher("; abd & this is what ;");
while(matcher.find()){
System.out.println("find start position "+matcher.start() +" find end position "+matcher.end()+" find for "+ matcher.group(0));
}
O/P
find start position 0 find end position 1 find for ;
find start position 25 find end position 26 find for ;
关于要匹配的 Java 模式;在 & 中跳过它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38690344/