Click here to watch on Youtube :
https://www.youtube.com/watch?v=FyPlgOYT0LA&list=UUhwKlOVR041tngjerWxVccw
RegexDemo.java
Output
Click the below link to download the code:
https://sites.google.com/site/ramj2eev1/home/javabasics/RegexDemo_study_methods.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/RegexDemo_study_methods
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/07583a7ceb95d30e4d41a36362b049aa5d1ec520/BasicJava/RegexDemo_study_methods/?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=FyPlgOYT0LA&list=UUhwKlOVR041tngjerWxVccw
RegexDemo.java
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
*
* Study Methods
*
*/
public class RegexDemo
{
public static void main(String[] args)
{
Pattern pattern = Pattern.compile("dog");
Matcher matcher = pattern.matcher("dog is friendly");
/*
* Study methods go through the input String and return a
* boolean indicating whether or not the pattern is found.
* Commonly used are matches and lookingAt methods.
*
* The matches and lookingAt methods both attempt to match an
* input sequence against a pattern. The difference, is that
* matches requires the entire input sequence to be matched,
* while lookingAt does not.
*/
System.out.println(matcher.lookingAt());
System.out.println(matcher.matches());
}
}
import java.util.regex.Pattern;
/**
*
* Study Methods
*
*/
public class RegexDemo
{
public static void main(String[] args)
{
Pattern pattern = Pattern.compile("dog");
Matcher matcher = pattern.matcher("dog is friendly");
/*
* Study methods go through the input String and return a
* boolean indicating whether or not the pattern is found.
* Commonly used are matches and lookingAt methods.
*
* The matches and lookingAt methods both attempt to match an
* input sequence against a pattern. The difference, is that
* matches requires the entire input sequence to be matched,
* while lookingAt does not.
*/
System.out.println(matcher.lookingAt());
System.out.println(matcher.matches());
}
}
Output
true
false
false
Click the below link to download the code:
https://sites.google.com/site/ramj2eev1/home/javabasics/RegexDemo_study_methods.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/RegexDemo_study_methods
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/07583a7ceb95d30e4d41a36362b049aa5d1ec520/BasicJava/RegexDemo_study_methods/?at=master
See also:
No comments:
Post a Comment