Maruthi Krishna has Published 870 Articles

Pattern compile() method in Java with Examples

Maruthi Krishna

Maruthi Krishna

Updated on 19-Nov-2019 09:22:46

794 Views

The pattern class of the java.regex package is a compiled representation of a regular expression.The compile() method of this class accepts a string value representing a regular expression and returns a Pattern object.Exampleimport java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class CompileExample {    public static void main( String args[] ) ... Read More

Matcher matches() method in Java with Examples

Maruthi Krishna

Maruthi Krishna

Updated on 19-Nov-2019 08:15:10

491 Views

The java.util.regex.Matcher class represents an engine that performs various match operations. There is no constructor for this class you can create/obtain an object of this class using the matches() method of the class java.util.regex.Pattern.The matches() method of this class matches the string with, the pattern represented by the regular expression ... Read More

Matcher find() method in Java with Example

Maruthi Krishna

Maruthi Krishna

Updated on 19-Nov-2019 08:13:12

867 Views

The java.util.regex.Matcher class represents an engine that performs various match operations. There is no constructor for this class you can create/obtain an object of this class using the matches() method of the class java.util.regex.Pattern.The find() method of this class tries to find the next subsequent input matching the current Matcher ... Read More

Matcher end() method in Java with Example

Maruthi Krishna

Maruthi Krishna

Updated on 19-Nov-2019 08:11:54

315 Views

The java.util.regex.Matcher class represents an engine that performs various match operations. There is no constructor for this class you can create/obtain an object of this class using the matches() method of the class java.util.regex.Pattern.The end() method of the Matcher class returns the offset after the last match represented by the ... Read More

Matcher start() method in Java with Examples

Maruthi Krishna

Maruthi Krishna

Updated on 19-Nov-2019 08:09:44

340 Views

The java.util.regex.Matcher class represents an engine that performs various match operations. There is no constructor for this class you can create/obtain an object of this class using the matches() method of the class java.util.regex.Pattern.The start() method of the Matcher class returns the starting index of the matched character.ExampleThe subexpression "[...]" ... Read More

How to match non-word boundaries using Java RegEx?

Maruthi Krishna

Maruthi Krishna

Updated on 19-Nov-2019 08:07:46

319 Views

You can match the non-word boundaries using the meta character “\B”.Example 1import java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Example {    public static void main(String args[]) {       //Reading String from user       System.out.println("Enter a String");       Scanner sc = new Scanner(System.in);   ... Read More

How to match word boundaries using Java RegEx?

Maruthi Krishna

Maruthi Krishna

Updated on 19-Nov-2019 08:06:01

498 Views

You can match the word boundaries using the meta character “\b”.Example 1import java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Example {    public static void main(String args[]) {       //Reading String from user       System.out.println("Enter a String");       Scanner sc = new Scanner(System.in);   ... Read More

How to match end of the input using Java RegEx?

Maruthi Krishna

Maruthi Krishna

Updated on 19-Nov-2019 08:04:07

564 Views

You can match the end of the input using the meta character “\z”.Exampleimport java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Example {    public static void main(String args[]) {       //Reading String from user       System.out.println("Enter a String");       Scanner sc = new Scanner(System.in); ... Read More

Regular Expression Metacharacter in Java

Maruthi Krishna

Maruthi Krishna

Updated on 19-Nov-2019 07:12:09

196 Views

The subexpression/metacharacter “\t” matches the tab spaces.Example 1import java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexExample {    public static void main( String args[] ) {       String regex = "\t";       Scanner sc = new Scanner(System.in);       System.out.println("Enter a string: ");     ... Read More

Regular Expression  Metacharacter in Java

Maruthi Krishna

Maruthi Krishna

Updated on 19-Nov-2019 07:04:02

327 Views

The subexpression/metacharacter “\b” matches the word boundaries when outside the brackets. Matches the backspace (0x08) when inside the brackets.Example 1import java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexExample {    public static void main( String args[] ) {       String regex = "\bbecause\b";       Scanner sc ... Read More

Advertisements