Maruthi Krishna has Published 951 Articles

Regular Expression "A" construct in Java

Maruthi Krishna

Maruthi Krishna

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

142 Views

The subexpression/metacharacter “\A” matches the beginning of the entire string.Example 1import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexExample {    public static void main( String args[] ) {       String regex = "\AHi";       String input = "Hi how are you welcome to Tutorialspoint";       ... Read More

Regular Expression "[^...]" construct in Java

Maruthi Krishna

Maruthi Krishna

Updated on 19-Nov-2019 06:17:16

123 Views

The subexpression/metacharacter “[^...]” matches any single character, not in brackets.Example 1import java.util.regex.Matcher; import java.util.regex.Pattern; public class SpecifiedCharacters {    public static void main( String args[] ) {       String regex = "[^hwtyoupi]";       String input = "Hi how are you welcome to Tutorialspoint";       ... Read More

Explain the sub-expression "[...]" in Java Regular expressions

Maruthi Krishna

Maruthi Krishna

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

265 Views

The subexpression “[...]” matches any single character specified in the brackets.Example 1import java.util.regex.Matcher; import java.util.regex.Pattern; public class SpecifiedCharacters {    public static void main( String args[] ) {       String regex = "[hwt]";       String input = "Hi how are you welcome to Tutorialspoint";     ... Read More

Regular Expression "re*" Metacharacter in Java

Maruthi Krishna

Maruthi Krishna

Updated on 18-Nov-2019 11:59:46

94 Views

The subexpression/metacharacter “re*” matches 0 or more 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 = "aabc*";       String input = "aabcabcaabcabbcaabcbcaabc";       Pattern p = Pattern.compile(regex); ... Read More

Explain Regular Expression "A" Metacharacter in Java

Maruthi Krishna

Maruthi Krishna

Updated on 18-Nov-2019 11:57:12

167 Views

The subexpression/metacharacter “\A” matches the beginning of the entire string.Example 1import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexExample {    public static void main( String args[] ) {       String regex = "\AHi";       String input = "Hi how are you welcome to Tutorialspoint";       ... Read More

Regular Expression "." (dot) Metacharacter in Java

Maruthi Krishna

Maruthi Krishna

Updated on 18-Nov-2019 10:29:25

842 Views

The subexpression/metacharacter “.” matches any single character except a newline.Example1import java.util.regex.Matcher; import java.util.regex.Pattern; public class MatchesAll {    public static void main( String args[] ) {       String regex = ".";       String input = "Hi how are you welcome to Tutorialspoint";       Pattern ... Read More

Regular Expression "$" (dollar) Metacharacter in Java

Maruthi Krishna

Maruthi Krishna

Updated on 18-Nov-2019 10:17:40

801 Views

The subexpression/metacharacter “$” matches the end of a line.Example 1import java.util.regex.Matcher; import java.util.regex.Pattern; public class EndWith {    public static void main( String args[] ) {       String regex = "Tutorialspoint$";       String input = "Hi how are you welcome to Tutorialspoint";       Pattern ... Read More

Regular Expression "^" (caret) Metacharacter in Java

Maruthi Krishna

Maruthi Krishna

Updated on 18-Nov-2019 10:12:52

454 Views

The subexpression/metacharacter “^” matches the beginning of a line. If you use this in a regular expression, it matches the sentence succeeding it in the input string.Example 1import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexExample {    public static void main( String args[] ) {       String regex = ... Read More

What is meant by re-throwing exceptions in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 01-Nov-2019 10:22:40

4K+ Views

When an exception is cached in a catch block, you can re-throw it using the throw keyword (which is used to throw the exception objects).While re-throwing exceptions you can throw the same exception as it is without adjusting it as −try {    int result = (arr[a])/(arr[b]);    System.out.println("Result of ... Read More

How to extract an HTML tag from a String using regex in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 17-Oct-2019 15:52:40

3K+ 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 regular expression with a String this class provides two methods namely −compile() − This method accepts a String representing ... Read More

Advertisements