Maruthi Krishna has Published 951 Articles

Sub-Expression "(?: re)" in Java Regular Expressions

Maruthi Krishna

Maruthi Krishna

Updated on 19-Nov-2019 09:56:16

128 Views

The subexpression/metacharacter “(?: re)” groups regular expressions without remembering the matched text.Exampleimport java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class PatternExample {    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 "(re)" Sub-Expression in Java

Maruthi Krishna

Maruthi Krishna

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

228 Views

The subexpression/metacharacter “( )” groups the regular expressions and remembers the matched text.Example 1import java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Example {    public static void main( String args[] ) {       String input = "Hello how are you welcome to Tutorialspoint";       String regex ... Read More

Explain the Metacharacter "B" in Java Regular Expressions.

Maruthi Krishna

Maruthi Krishna

Updated on 19-Nov-2019 09:50:33

155 Views

The subexpression/metacharacter “\B” matches the non-word boundaries.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 = "\Bcause";       Scanner sc = new Scanner(System.in);       System.out.println("Enter a string: ");     ... Read More

How to match a character from given string including case using Java regex?

Maruthi Krishna

Maruthi Krishna

Updated on 19-Nov-2019 09:27:27

313 Views

The java.util.regex package of java provides various classes to find particular patterns in character sequences. The pattern class of this package is a compiled representation of a regular expression.To match a specific character from the given input string −Get the input string.This compile() method of this class accepts a string ... Read More

Pattern compile() method in Java with Examples

Maruthi Krishna

Maruthi Krishna

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

529 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

364 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

657 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

188 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

222 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

236 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

Advertisements