Home » Core Java » util » regex » Pattern


java.util.regex.Pattern Example

Pattern class represents a compiled representation of a regular expression. This is defined in the java.util.regex package as a final class. A regular expression is specified as a string. This string is to be first compiled into an instance of this class using the Pattern.compile() static method. This instance is used by a Matcher class to perform match operation. This ...

Read More »

Extract HTML Links with Java Regular Expression example

With this example we shall show you how to extract and process HTML links with Java Regular expression. You can follow the basic techniques in this article and learn how to process many other HTML elements and thus create a very basic HTML parser that you can easily embed in your application. So the things we want to do is: ...

Read More »

Validate HTML Tag with Java Regular Expression example

In this tutorial we are going to see how to validate HTML Tag format. In general, validating HTML with regular expressions in not the optimal method. You should use an HTML parser for that matter. But when you want to validate the basic HTML format, quickly in your application, Regular Expressions will do. So the basic policy of HTML tags ...

Read More »

Validate Date with Java Regular Expression example

In this tutorial we are going to see how to validate date format with Java Regular Expressions.The basic policy about  date of the form “dd/mm/yyyy” is that: It should start with two digits from 01 – 31 or from 1 – 31. It must be followed by ‘/’. It should be followed by two digits from 01- 12 or from ...

Read More »

Validate Email Address with Java Regular Expression example

Email validation is a very frequent requirement in many applications. Basically the main policy that email format follows is that it: Has to start with characters, digits or ‘_’, ‘-‘, ‘+’ symbols The above group can be followed with a ‘.’ and the same pattern as the first group. Then it must have exactly one ‘@’ character. The domain name ...

Read More »

How To Validate Hex Color Code With Regular Expression

In this tutorial we are going to see how to create a simple application that validates Hexadecimal Color Codes. The main policy abount Hex Color Codes denotes that it has to: Start with ‘#’ tag. Contain any lower case or uppercase characters from ‘a’ to ‘f’. Contain digits from ‘0’ to ‘9’. Have a length of 3 or 6 without ...

Read More »