Maruthi Krishna has Published 951 Articles

How to match word boundaries using Java RegEx?

Maruthi Krishna

Maruthi Krishna

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

315 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

423 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

How to match non-digits using Java Regular Expression (RegEx)

Maruthi Krishna

Maruthi Krishna

Updated on 19-Nov-2019 07:59:06

1K+ Views

You can match non-digit character using the meta character "\D".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 digits using Java Regular Expression (RegEx)

Maruthi Krishna

Maruthi Krishna

Updated on 19-Nov-2019 07:56:43

2K+ Views

You can match digits in a given string using the meta character "\d" or by using the following expression : [0-9]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"); ... Read More

How to match a non-white space equivalent using Java RegEx?

Maruthi Krishna

Maruthi Krishna

Updated on 19-Nov-2019 07:51:10

882 Views

You can match the non-white space characters using the meta character "\S".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

How to match a white space equivalent using Java RegEx?

Maruthi Krishna

Maruthi Krishna

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

1K+ Views

The metacharacter "\s" matches the white space characters in the given string.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 a non-word character using Java RegEx?

Maruthi Krishna

Maruthi Krishna

Updated on 19-Nov-2019 07:44:37

1K+ Views

All the characters other than the English alphabet (both cases) and, digits (0 to 9) are considered as non-word characters. You can match them using the meta character “\W”.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 ... Read More

How to match word characters using Java RegEx?

Maruthi Krishna

Maruthi Krishna

Updated on 19-Nov-2019 07:41:03

764 Views

The English alphabet (both cases) and, digits (0 to 9) are considered as word characters. You can match them using the meta character “\w”.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     ... Read More

How to match one of the two given expressions using Java RegEx?

Maruthi Krishna

Maruthi Krishna

Updated on 19-Nov-2019 07:38:28

1K+ Views

Using the or logical operator | of Java regular expressions you can match either of two given expressions.For example, if you need your regular expression should match more than one expression you can do so by separating the required expressions by “|”.Example 1import java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class ... Read More

How to match n number of occurrences of an expression using Java RegEx?

Maruthi Krishna

Maruthi Krishna

Updated on 19-Nov-2019 07:35:53

1K+ Views

The greedy quantifiers provided by Java allows you to match the multiple occurrences of an expression. Where, Exp{n} impels the occurrence of the expression exp exactly n times.Exp{n, } impels the occurrence of the expression exp at least n times.Exp{n, m} impels occurrence of the expression exp at least n ... Read More

Advertisements