Click here to watch on Youtube :
https://www.youtube.com/watch?v=kRU23JcC55U&list=UUhwKlOVR041tngjerWxVccw
RegexDemo.java
Output
Click the below link to download the code:
https://sites.google.com/site/ramj2eev1/home/javabasics/RegexDemo_boundary_nondigit.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/RegexDemo_boundary_nondigit
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/576579fab6c376d5ecd7cb5b7402b7fd1a7c4ae3/BasicJava/RegexDemo_boundary_nondigit/?at=master
See also:
All JavaEE Videos Playlist
All JavaEE Videos
All JAVA EE Links
Servlets Tutorial
All Design Patterns Links
JDBC Tutorial
Java Collection Framework Tutorial
JAVA Tutorial
Kids Tutorial
https://www.youtube.com/watch?v=kRU23JcC55U&list=UUhwKlOVR041tngjerWxVccw
RegexDemo.java
import java.util.regex.Pattern;
public class RegexDemo
{
public static void main(String[] args)
{
/*
* returns true if the string contains 0 or more non-digits
*/
System.out.println(Pattern.matches("\\D*", "abcde")); // True
System.out.println(Pattern.matches("\\D*", "abcde123")); // False
System.out.println("----------------------------------");
/*
* Boundary Matchers example ^ denotes start of the line $ denotes end
* of the line
*/
System.out.println(Pattern.matches("^This$", "This is Chaitanya")); // False
System.out.println(Pattern.matches("^This$", "This")); // True
System.out.println(Pattern.matches("^This$", "Is This Chaitanya")); // False
}
}
public class RegexDemo
{
public static void main(String[] args)
{
/*
* returns true if the string contains 0 or more non-digits
*/
System.out.println(Pattern.matches("\\D*", "abcde")); // True
System.out.println(Pattern.matches("\\D*", "abcde123")); // False
System.out.println("----------------------------------");
/*
* Boundary Matchers example ^ denotes start of the line $ denotes end
* of the line
*/
System.out.println(Pattern.matches("^This$", "This is Chaitanya")); // False
System.out.println(Pattern.matches("^This$", "This")); // True
System.out.println(Pattern.matches("^This$", "Is This Chaitanya")); // False
}
}
Output
true
false
----------------------------------
false
true
false
false
----------------------------------
false
true
false
Click the below link to download the code:
https://sites.google.com/site/ramj2eev1/home/javabasics/RegexDemo_boundary_nondigit.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/RegexDemo_boundary_nondigit
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/576579fab6c376d5ecd7cb5b7402b7fd1a7c4ae3/BasicJava/RegexDemo_boundary_nondigit/?at=master
See also:
No comments:
Post a Comment