请教同志们一个问题,如何在java中模拟SQL中的like? 现在碰到一个需求,要求使用java来模拟sql中的like,返回值为bool,现在想到的是使用indexOf,不知道有没有更好的方式,谢谢大家。。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用正则来匹配,想怎么like都行。 正则表达式……like %abc% 正则就是 (.+)(abc)(.+) 正则啥呀...部分包含字符串....indexOf是正解...有这么搞这么复杂吗 indexOf应该很高效了 contains也可以 根据chensuper的提示,我自己写了一个关于正则的东西 但是总是运行不出来结果,请大家帮我看看public class TestLike{ public static void main(String[] str) { String str1="abc"; Pattern p = Pattern.compile(" (.+)(abc)(.+)"); //(.+)是表示%吧? Matcher m = p.matcher(str1); while(m.find()) { System.out.println(m.group()); } }} 三道小题 java生成文本文件,然后上传ftp服务器 在SWING中用JMenuItem唤出JLabel,并写日期不成功。(附源代码)我急需。谢谢个位了 字节流读取中文字符的问题 汉明码? java连接domino lotus数据库的问题 需要什么条件能够解释执行??? jdk1.3下,不能运行程序,请解决! 散分100:领到年终奖5000元;顺便给兄弟们拜个晚年!!! could not load the Java virtual machine.program will exit! String怎么替换"\" java 中public void paint()方法问题
部分包含字符串....indexOf是正解...有这么搞这么复杂吗
public class TestLike
{
public static void main(String[] str)
{
String str1="abc";
Pattern p = Pattern.compile(" (.+)(abc)(.+)"); //(.+)是表示%吧?
Matcher m = p.matcher(str1);
while(m.find()) {
System.out.println(m.group());
}
}
}