Maruthi Krishna has Published 951 Articles

Pattern CASE_INSENSITIVE field in Java with examples

Maruthi Krishna

Maruthi Krishna

Updated on 20-Nov-2019 06:05:24

2K+ Views

This CASE_INSENSITIVE field of the Pattern class matches characters irrespective of case. When you use this as flag value to the compile() method and if you search for characters using regular expressions characters of both cases will be matched.Note − By default, this flag matches only ASCII charactersExample 1import java.util.Scanner; ... Read More

Pattern flags() method in Java with examples

Maruthi Krishna

Maruthi Krishna

Updated on 20-Nov-2019 05:59:25

398 Views

The pattern class of 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, the following is the signature of this method.static Pattern compile(String regex)Another variant of this method accepts an integer ... Read More

Pattern toString() method in Java with examples

Maruthi Krishna

Maruthi Krishna

Updated on 20-Nov-2019 05:54:48

122 Views

The Pattern class of the java.util.regex package is a compiled representation of a regular expression.The toString() method of this class returns the string representation of the regular expression using which the current Pattern was compiled.Example1import java.util.Scanner; import java.util.regex.Pattern; public class Example {    public static void main( String args[] ) ... Read More

Pattern splitAsStream() method in Java with examples

Maruthi Krishna

Maruthi Krishna

Updated on 20-Nov-2019 05:52:46

239 Views

The Pattern class of the java.util.regex package is a compiled representation of a regular expression.The splitAsStream() method of this class accepts a CharSequence object, representing the input string as a parameter and, at each match, it splits the given string into a new substring and returns the result as a ... Read More

Pattern split() method in Java with examples

Maruthi Krishna

Maruthi Krishna

Updated on 20-Nov-2019 05:51:14

506 Views

The Pattern class of the java.util.regex package is a compiled representation of a regular expression.The split() method of this class accepts a CharSequence object, representing the input string as a parameter and, at each match, it splits the given string into a new token and returns the string array holding ... Read More

Pattern pattern() method in Java with examples

Maruthi Krishna

Maruthi Krishna

Updated on 20-Nov-2019 05:47:04

1K+ 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.The pattern() method of the Pattern class fetches and returns the regular expression in the string format, using which the current pattern ... Read More

Pattern matches() method in Java with examples

Maruthi Krishna

Maruthi Krishna

Updated on 20-Nov-2019 05:44:56

461 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.The matches() method of the Pattern class accepts −A string value representing the regular expression.An object of the CharSequence class representing the ... Read More

Pattern quote() method in Java with examples

Maruthi Krishna

Maruthi Krishna

Updated on 20-Nov-2019 05:42:59

2K+ 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. The quote() method of this class accepts a string value and returns a pattern string that would match the given string i.e. ... Read More

Explain the Java regular expression construct "re?".

Maruthi Krishna

Maruthi Krishna

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

113 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

120 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

Advertisements