正则排除字符串

阅读更多

排除字符串 abc

 

((?!abc).)*

 

排除字符串abc或者def

((?!(abc|def)).)*

 

取出想取出内层的p标签 : 

吃饭

比如  

吃饭

package com.cases;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class P {

	public static void main(String[] args) {
		String p= "

吃饭

"; Pattern pattern = Pattern.compile("\\((?!\\).)*?\\"); Matcher matcher = pattern.matcher(p); while (matcher.find()) { String s = matcher.group(0); System.out.println(s); } } }

 

 

 

 

 

 

你可能感兴趣的:(正则排除字符串)