public class RegExp {
public boolean match(String reg, String str) {
return Pattern.matches(reg, str);
}
public List<String> find(String reg, String str) {
Matcher matcher = Pattern.compile(reg).matcher(str);
List<String> list = new ArrayList<String>();
while (matcher.find()) {
list.add(matcher.group());
}
return list;
}
public List<String> find(String reg, String str, int index) {
Matcher matcher = Pattern.compile(reg).matcher(str);
List<String> list = new ArrayList<String>();
while (matcher.find()) {
list.add(matcher.group(index));
}
return list;
}
public String findString(String reg, String str, int index) {
String returnStr = null;
List<String> list = this.find(reg, str, index);
if (list.size() != 0)
returnStr = list.get(0);
return returnStr;
}
public String findString(String reg, String str) {
String returnStr = null;
List<String> list = this.find(reg, str);
if (list.size() != 0)
returnStr = list.get(0);
return returnStr;
}
public static void main(String[] args) {
RegExp re = new RegExp();
System.out.println(re.find("(a)b", "ababab", 1));
}
}
public class ParseKeyword {
public List<String> getKeywords(String p){
String reg = "(?<=(?<!\\\\)\\$\\{)(.*?)(?=(?<!\\\\)\\})";
RegExp re = new RegExp();
List<String> list = re.find(reg, p);
return list;
}
public static void main(String[] args) {
ParseKeyword p = new ParseKeyword();
System.out.println(p.getKeywords("a${a}a"));
System.out.println(p.getKeywords("a\\${a}a"));
System.out.println(p.getKeywords("a${a\\}a"));
System.out.println(p.getKeywords("a${a\\}a}a"));
System.out.println(p.getKeywords("a${a}a${"));
System.out.println(p.getKeywords("a${ab}a${a}"));
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有