Java Regex
Java Regex The Java Regex or Regular Expression is an API to define pattern for searching or manipulating strings . It is widely used to define constraint on strings such as password and email validation. After learning java regex tutorial, you will be able to test your own regular expressions by the Java Regex Tester Tool. Java Regex API provides 1 interface and 3 classes in java.util.regex package. Contoh: import java.util.regex.*; public class RegexExample1{ public static void main(String args[]){ //1st way Pattern p = Pattern.compile("peng.*");//. represents single character Matcher m = p.matcher("penggaris"); boolean b = m.matches(); //2nd way boolean b2=Pattern.compile(".s").matcher("as").matches(); //3rd way boolean b3 = Pattern.matches(".s", "as"); System.out.println(b+" "+b2+" "+b3); }} Nota dan sumber daripada: http://www.javatpoint.com/java-regex http://ww