Click here to watch in Youtube :
https://www.youtube.com/watch?v=KliNEG2pdYI&list=UUhwKlOVR041tngjerWxVccw
Click the below Image to Enlarge
Java Tutorial : Java String [matches(String regex) method] |
/* * public boolean matches(String regex) * * Parameters: * ---------- * regex - the regular expression to which this * string is to be matched * * Returns: * ------- * true if, and only if, this string matches the * given regular expression * * Throws: * ------ * PatternSyntaxException - if the regular * expression's syntax is invalid */ public class MatchesDemo { public static void main(String[] args) { String str = new String("Welcome to ramj2ee.com"); System.out .print("\"Welcome to ramj2ee.com\".matches(\"Welcome(.*)\") = "); System.out.println(str.matches("Welcome(.*)")); System.out .print("\"Welcome to ramj2ee.com\".matches(\"(.*)ramj2ee(.*)\") = "); System.out.println(str.matches("(.*)ramj2ee(.*)")); } }
"Welcome to ramj2ee.com".matches("Welcome(.*)") = true "Welcome to ramj2ee.com".matches("(.*)ramj2ee(.*)") = true
https://sites.google.com/site/javaee4321/java/StringDemo_matches_App.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/StringDemo_matches_App
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/f763f2167329fa6e35d47d9d3a5195613480d629/BasicJava/StringDemo_matches_App/?at=master
See also:
No comments:
Post a Comment