Maruthi Krishna has Published 995 Articles

How to create a directory hierarchy using Java?

Maruthi Krishna

Maruthi Krishna

Updated on 12-Mar-2024 18:37:31

831 Views

The class named File of the java.io package represents a file or directory (path names) in the system. This class provides various methods to perform various operations on files/directories. The mkdir() method of this class creates a directory with the path represented by the current object. Creating directory hierarchy There ... Read More

Checking for valid email address using regular expressions in Java

Maruthi Krishna

Maruthi Krishna

Updated on 19-Feb-2024 04:14:12

64K+ Views

To verify whether a given input string is a valid e-mail id match it with the following is the regular expression to match an e-mail id −"^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+$"Where, ^ matches the starting of the sentence.[a-zA-Z0-9+_.-] matches one character from the English alphabet (both cases), digits, "+", "_", "." and, "-" before ... Read More

Pattern UNICODE_CASE field in Java with Examples

Maruthi Krishna

Maruthi Krishna

Updated on 07-Dec-2023 10:03:09

632 Views

Enables Unicode-aware case folding. When you use this as flag value to the compile() method along with the CASE_INSENSITIVE flag and if you search for Unicode characters using regular expressions Unicode characters of both cases will be matched. Example import java.util.regex.Matcher; import java.util.regex.Pattern; public class UNICODE_CASE_Example { public static void main( String ... Read More

Pattern UNIX_LINES field in Java with Examples

Maruthi Krishna

Maruthi Krishna

Updated on 07-Dec-2023 09:56:32

193 Views

This flag enables Unix lines mode. In the Unix lines mode, only '' is used as a line terminator and ‘\r’ is treated as a literal character. Example 1 import java.util.regex.Matcher; import java.util.regex.Pattern; public class LTERAL_Example { public static void main(String[] args) { String input = "This ... Read More

Pattern UNICODE_CHARACTER_CLASS field in Java with examples

Maruthi Krishna

Maruthi Krishna

Updated on 06-Dec-2023 12:41:53

408 Views

Enables the Unicode version of Predefined character classes and POSIX character classes. Example import java.util.regex.Matcher; import java.util.regex.Pattern; public class UNICODE_CHARACTER_CLASS_Example { public static void main( String args[] ) { String regex = "\u00de"; //Compiling the regular expression ... Read More

Pattern CANON_EQ field in Java with examples

Maruthi Krishna

Maruthi Krishna

Updated on 06-Dec-2023 12:36:04

727 Views

The CANON_EQ field of the Pattern class matches two characters only if they are canonically equal. When you use this as flag value to the compile() method, two characters will be matched if and only if their full canonical decompositions are equal. Where canonical decomposition is one of the Unicode text ... Read More

Pattern LITERAL field in Java with examples

Maruthi Krishna

Maruthi Krishna

Updated on 05-Dec-2023 10:52:51

837 Views

Enables literal parsing of the pattern. In this, all the characters including escape sequences and, meta-characters don’t have any special meaning they are treated as literal characters. For example, normally if you search for the regular expression “^This” in the given input text it matches the lines starting with the word ... Read More

Pattern MULTILINE field in Java with examples

Maruthi Krishna

Maruthi Krishna

Updated on 05-Dec-2023 10:40:19

2K+ Views

Enables multiline mode in general, the ^ and $ meta characters matches the start and end of the given input with the specified characters irrespective of the number of lines in it. Example 1 import java.util.regex.Matcher; import java.util.regex.Pattern; public class MULTILINE_Example { public static void main( String args[] ) { ... Read More

What is the easiest way to reverse a String in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 05-Dec-2023 09:29:13

807 Views

Built-in reverse() method The StringBuffer class provides you a method named reverse(). It reverses the contents of the current StringBuffer object and returns the resultant StringBuffer object. It is the easiest way to reverse a Sting using Java. To do so − Instantiate the StringBuffer class by passing the required String as ... Read More

How to validate given date formats like MM-DD-YYYY using regex in java?

Maruthi Krishna

Maruthi Krishna

Updated on 05-Dec-2023 09:18:50

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

1 2 3 4 5 ... 100 Next
Advertisements