Maruthi Krishna has Published 870 Articles

Regular Expression "G" Metacharacter in Java

Maruthi Krishna

Maruthi Krishna

Updated on 19-Nov-2019 06:54:10

860 Views

The subexpression/metacharacter “\G” matches the point where the last match finished.Exampleimport java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexExample {    public static void main( String args[] ) {       String regex = "\G[0-9]";       Scanner sc = new Scanner(System.in);       System.out.println("Enter a string: ... Read More

Regular Expression "D" Metacharacter in Java

Maruthi Krishna

Maruthi Krishna

Updated on 19-Nov-2019 06:53:22

645 Views

The subexpression/metacharacter “\D” matches the non-digits.Example 1import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexExample {    public static void main( String args[] ) {       String regex = "\D";       String input = "This is sample text 12 24 56 89 24";       Pattern p ... Read More

Regular Expression "d" construct in Java

Maruthi Krishna

Maruthi Krishna

Updated on 19-Nov-2019 06:49:37

231 Views

The subexpression/metacharacter “\d” matches the digits.Example 1import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexExample {    public static void main( String args[] ) {       String regex = "\d 24";       String input = "This is sample text 12 24 56 89 24";       Pattern ... Read More

Regular Expression "S" Metacharacter in Java

Maruthi Krishna

Maruthi Krishna

Updated on 19-Nov-2019 06:47:29

739 Views

The subexpression/metacharacter “\S” matches the non-white space characters.Example 1import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexExample {    public static void main( String args[] ) {       String regex = "\S";       String input = "Hello how are you welcome to Tutorialspoint !";       Pattern ... Read More

Explain Regular Expression "s" Metacharacter in Java

Maruthi Krishna

Maruthi Krishna

Updated on 19-Nov-2019 06:45:34

176 Views

The subexpression/metacharacter “\s” matches the white space equivalent.Example 1import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexExample {    public static void main( String args[] ) {       String regex = "\s";       String input = "Hello how are you welcome to Tutorialspoint !";       Pattern ... Read More

Regular Expression "W" Metacharacter in Java

Maruthi Krishna

Maruthi Krishna

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

1K+ Views

The subexpression/metacharacter “\W” matches the non-word characters.Example1import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexExample {    public static void main(String args[]) {       String regex = "\W!";       String input = "Hello how are you welcome to Tutorialspoint !";       Pattern p = Pattern.compile(regex);   ... Read More

Explain Regular Expression "w" Metacharacter in Java

Maruthi Krishna

Maruthi Krishna

Updated on 19-Nov-2019 06:41:38

239 Views

The subexpression/metacharacter “\w” matches the word characters i.e. a to z and A to Z and 0 to 9.Example 1import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexExample {    public static void main( String args[] ) {       String regex = "\w to";       String input = ... Read More

Regular Expression a|b Metacharacter in Java

Maruthi Krishna

Maruthi Krishna

Updated on 19-Nov-2019 06:40:39

407 Views

The subexpression/metacharacter “a| b” matches either a or b.Example 1import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexExample {    public static void main( String args[] ) {       String regex = "Hello|welcome";       String input = "Hello how are you welcome to Tutorialspoint";       Pattern ... Read More

Regular Expression re{ n, m} Metacharacter in Java

Maruthi Krishna

Maruthi Krishna

Updated on 19-Nov-2019 06:37:06

210 Views

The subexpression/metacharacter “re{ n, m}” matches at least n and at most m occurrences of the preceding expression.Example 1import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexExample {    public static void main( String args[] ) {       String regex = "xyy{2, 4}";       String input = "xxyyzxxyyyyxyyzxxyyzz"; ... Read More

Regular Expression re{ n} Metacharacter in Java

Maruthi Krishna

Maruthi Krishna

Updated on 19-Nov-2019 06:34:52

147 Views

The subexpression/metacharacter “re{ n}” matches exactly n number of occurrences of the preceding expression.Example 1import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexExample {    public static void main( String args[] ) {       String regex = "to{1}";       String input = "Welcome to Tutorialspoint";       ... Read More

Advertisements