Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 2nd, 2012  |  syntax: None  |  size: 0.36 KB  |  hits: 7  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Regex from javascript to java
  2. Matcher matcher = Pattern.compile("c").matcher("abcde");
  3. System.out.println(matcher.find()?matcher.start():-1);
  4.  
  5.  
  6. Matcher matcher2 = Pattern.compile("[^\d]").matcher("123bed567");
  7. System.out.println(matcher2.find());
  8.  
  9. Matcher matcher3 = Pattern.compile("\d").matcher("asdgh");
  10. System.out.println(matcher3.find()?matcher3.group():null);