D donyad Unregistered / Unconfirmed GUEST, unregistred user! 2003-07-11 #1 正则里面"abc"应该匹配所有含abc的串 php里ereg("abc", "aabcd")就是true 但java1.4.2forwin32出来就是false 为什么?
Z ZRWeng Unregistered / Unconfirmed GUEST, unregistred user! 2003-07-11 #2 不会吧, import java.util.regex.*; public class TryTest{ public static void main(String[] args) { Pattern p = Pattern.compile("abc"); Matcher m = p.matcher("aabc"); if (m.find()) System.out.println("Yes"); else System.out.println("No"); } }
不会吧, import java.util.regex.*; public class TryTest{ public static void main(String[] args) { Pattern p = Pattern.compile("abc"); Matcher m = p.matcher("aabc"); if (m.find()) System.out.println("Yes"); else System.out.println("No"); } }
D donyad Unregistered / Unconfirmed GUEST, unregistred user! 2003-07-29 #3 那这个就奇怪了 偶添的两行咋就不行呢? import java.util.regex.*; public class TryTest{ public static void main(String[] args) { Pattern p = Pattern.compile("abc"); Matcher m = p.matcher("aabc"); if (m.find()) System.out.println("Yes"); else System.out.println("No"); if(Pattern.matches("abc", "aabc")) System.out.println("Match"); else System.out.println("not Match"); } }
那这个就奇怪了 偶添的两行咋就不行呢? import java.util.regex.*; public class TryTest{ public static void main(String[] args) { Pattern p = Pattern.compile("abc"); Matcher m = p.matcher("aabc"); if (m.find()) System.out.println("Yes"); else System.out.println("No"); if(Pattern.matches("abc", "aabc")) System.out.println("Match"); else System.out.println("not Match"); } }