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

Untitled

By: a guest on Jun 22nd, 2012  |  syntax: None  |  size: 0.40 KB  |  hits: 18  |  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. validate string with regex on android
  2. private static boolean IsMatch(String s, String pattern) {
  3.          try {
  4.              Pattern patt = Pattern.compile(pattern);
  5.              Matcher matcher = patt.matcher(s);
  6.              return matcher.matches();
  7.          } catch (RuntimeException e) {
  8.            return false;
  9.          }  
  10. }
  11.  
  12.  
  13.  
  14. String regex ="[^*;$]";
  15. System.out.println(IsMatch(url,regex));