Maruthi Krishna has Published 870 Articles

Matcher replaceFirst() method in Java with Examples

Maruthi Krishna

Maruthi Krishna

Updated on 20-Nov-2019 06:31:48

239 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 replaceFirst() method of this (Matcher) class accepts a string value and, replaces the first matched subsequence ... Read More

Matcher replaceAll() method in Java with Examples

Maruthi Krishna

Maruthi Krishna

Updated on 20-Nov-2019 06:29:06

3K+ 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 replaceAll() method of this (Matcher) class accepts a string value, replaces all the matched subsequences in ... Read More

Matcher pattern() method in Java with Examples

Maruthi Krishna

Maruthi Krishna

Updated on 20-Nov-2019 06:26:02

373 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 pattern() method of this (Matcher) class fetches and returns a Pattern (object) interpreted by the current ... Read More

Pattern asPredicate() method in Java with examples

Maruthi Krishna

Maruthi Krishna

Updated on 20-Nov-2019 06:23:35

323 Views

The Predicate interface of the java.util.function package can be used as a target for lambda expressions. The test method of this interface accepts a value ad validates it with the current value of the Predicate object. This method returns true in-case of a match, else false.The asPredicate() method of the ... Read More

Explain the Java regular expression construct "re?".

Maruthi Krishna

Maruthi Krishna

Updated on 19-Nov-2019 10:17:36

191 Views

The subexpression/metacharacter “re?” matches 0 or 1 occurrence 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 = "Wel?";       String input = "Welcome to Tutorialspoint";       Pattern p ... Read More

Explain the Sub-Expression "(?> re)" in Java Regular Expressions

Maruthi Krishna

Maruthi Krishna

Updated on 19-Nov-2019 09:57:49

183 Views

The subexpression/metacharacter “(?> re)” matches the independent pattern without backtracking.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

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

Maruthi Krishna

Maruthi Krishna

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

201 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

339 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

237 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

400 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

Advertisements