Maruthi Krishna has Published 951 Articles

Regular Expression E Metacharacter in Java.

Maruthi Krishna

Maruthi Krishna

Updated on 10-Jan-2020 11:12:56

460 Views

The subexpression/metacharacter “\E” ends the quoting begun with \Q. i.e. you can escape metacharacters in the regular expressions by placing them in between \Q and \E. For example, the expression [aeiou] matches the strings with vowel letters in it.Example Live Demoimport java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class SampleProgram {   ... Read More

PatternSyntaxException class in Java regular expressions

Maruthi Krishna

Maruthi Krishna

Updated on 10-Jan-2020 11:07:19

88 Views

The PatternSyntaxException class represents an unchecked exception thrown in case of a syntax error in regex string. This class contains three main methods namely −getDescription() − Returns the description of the error.getIndex() − Returns the error index.getPattern() − Returns the regular expression pattern with error.getMessage() − Returns the complete message congaing ... Read More

Java regex program to add space between a number and word in Java.

Maruthi Krishna

Maruthi Krishna

Updated on 10-Jan-2020 10:58:11

2K+ Views

You can form matched groups in the regular expression by separating the expressions with parenthesis. In following regular expression the first group matches digits and the second group matches the English alphabet −(\d)([A-Za-z])In short, it matches the part in the input string where a digit followed by an alphabet.Since the ... Read More

Java regex program to verify whether a String contains at least one alphanumeric character.

Maruthi Krishna

Maruthi Krishna

Updated on 10-Jan-2020 10:53:56

7K+ Views

Following regular expression matches a string that contains at least one alphanumeric characters −"^.*[a-zA-Z0-9]+.*$";Where, ^.* Matches the string starting with zero or more (any) characters.[a-zA-Z0-9]+ Matches at least one alpha-numeric character..*$ Matches the string ending with zero or more (ant) characters.Example 1 Live Demoimport java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class ... Read More

How to check multiple regex patterns against an input? Using Java.

Maruthi Krishna

Maruthi Krishna

Updated on 10-Jan-2020 10:47:35

4K+ Views

The "|" meta character: The meta character "|" in Java regular expressions allows you to match more than one regular expressions for example if you need to match a particular input text with more than one expression you need to separate them using it as:exp1|exp2|exp3Example Live Demoimport java.util.Scanner; import java.util.regex.Matcher; import ... Read More

MatchResult start(int group) method in Java with examples.

Maruthi Krishna

Maruthi Krishna

Updated on 10-Jan-2020 10:27:43

43 Views

The java.util.regex.MatcheResult interface provides methods to retrieve the results of a match.You can get an object of this interface using the toMatchResult() method of the Matcher class. This method returns a MatchResult object which represents the match state of the current matcher.The end(int group) method of this interface accepts an integer ... Read More

MatchResult start() method in Java with examples.

Maruthi Krishna

Maruthi Krishna

Updated on 10-Jan-2020 10:24:36

60 Views

The java.util.regex.MatcheResult interface provides methods to retrieve the results of a match.You can get an object of this interface using the toMatchResult() method of the Matcher class. This method returns a MatchResult object which represents the match state of the current matcher.The start() method of this interface returns the beginning index ... Read More

Character class p{javaMirrored} Java regex.

Maruthi Krishna

Maruthi Krishna

Updated on 10-Jan-2020 10:20:10

300 Views

This character class \p{javaMirrored} matches upper case letters. This class matches the characters which returns true when passed as a parameter to the isMirrored() method of the java.lang.Character class.Example 1 Live Demoimport java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexExample {    public static void main(String args[]) {       ... Read More

Character class p{javaWhitespace} Java regex in java.

Maruthi Krishna

Maruthi Krishna

Updated on 10-Jan-2020 10:09:24

323 Views

This character class \p{javaWhitespace} matches spaces. This class matches the characters which returns true when passed as a parameter to the isWhitespace() method of the java.lang.Character class.Example 1 Live Demoimport java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexExample {    public static void main(String args[]) {       //Reading String ... Read More

Character class p{javaUpperCase} Java regex.

Maruthi Krishna

Maruthi Krishna

Updated on 10-Jan-2020 10:05:40

513 Views

This character class \p{javaUpperCase} matches upper case letters. This class matches the characters which returns true when passed as a parameter to the isUpperCase() method of the java.lang.Character class.Example 1 Live Demoimport java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexExample {    public static void main(String args[]) {       ... Read More

Advertisements