Click here to watch in Youtube : 
https://www.youtube.com/watch?v=u7wp4xPH0QI&list=UUhwKlOVR041tngjerWxVccw
RegexDemo.java
Output
Click the below link to download the code:
https://sites.google.com/site/ramj2eev1/home/javabasics/RegexDemo_lookingAt.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/RegexDemo_lookingAt
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/ef02c9011c18b0aa670526ba89cc11f493b9b854/BasicJava/RegexDemo_lookingAt/?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=u7wp4xPH0QI&list=UUhwKlOVR041tngjerWxVccw
RegexDemo.java
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RegexDemo
{
private static final String REGEX = "bar";
private static final String INPUT = "barooooooooooooooo";
public static void main(String[] args)
{
Pattern pattern = Pattern.compile(REGEX);
Matcher matcher = pattern.matcher(INPUT);
System.out.println("REGEX is: " + REGEX);
System.out.println("INPUT is: " + INPUT);
/*
* Returns:true if, and only if, a prefix of the input sequence matches
* this matcher's pattern.
*/
System.out.println("lookingAt(): " + matcher.lookingAt());
      
/*
* Returns:true if, and only if, the entire region sequence matches this
* matcher's pattern
*/
System.out.println("matches(): " + matcher.matches());
}
}
import java.util.regex.Pattern;
public class RegexDemo
{
private static final String REGEX = "bar";
private static final String INPUT = "barooooooooooooooo";
public static void main(String[] args)
{
Pattern pattern = Pattern.compile(REGEX);
Matcher matcher = pattern.matcher(INPUT);
System.out.println("REGEX is: " + REGEX);
System.out.println("INPUT is: " + INPUT);
/*
* Returns:true if, and only if, a prefix of the input sequence matches
* this matcher's pattern.
*/
System.out.println("lookingAt(): " + matcher.lookingAt());
/*
* Returns:true if, and only if, the entire region sequence matches this
* matcher's pattern
*/
System.out.println("matches(): " + matcher.matches());
}
}
Output
REGEX is: bar
INPUT is: barooooooooooooooo
lookingAt(): true
matches(): false
INPUT is: barooooooooooooooo
lookingAt(): true
matches(): false
Click the below link to download the code:
https://sites.google.com/site/ramj2eev1/home/javabasics/RegexDemo_lookingAt.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/RegexDemo_lookingAt
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/ef02c9011c18b0aa670526ba89cc11f493b9b854/BasicJava/RegexDemo_lookingAt/?at=master
See also:
 


 
No comments:
Post a Comment