In this tutorial we are going to see how to validate image file format with Java Regular Expressions. This is vary userful for example when you create an image uploader and you want to make sure that the user does not upload an illegal file to your system. Of cource this is one of many countermesures you should consider. The ...
Read More »Home » Core Java » util » regex »
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 Time In 24 Hours Format with Java Regular Expression example
In this tutorial we are going to see how to validate 24 Hours time format with Java Regular Expressions.The basic policy about the 24 hours format is that: It should start with two digits from 00 to 23. It must be followed by ‘:’. It should be followed by two digits from 00 to 59. ...
Read More »Validate Time In 12 Hours Format with Java Regular Expression example
In this tutorial we are going to see how to validate 12 Hours time format with Java Regular Expressions.The basic policy about the 12 hours format is that: It should start with two digits from 00 to 12. It must be followed by ‘:’. It should be followed by two digits from 00 to 59. Then, only one white space ...
Read More »Validate IP Address with Java Regular Expression example
With this example we shall show you how to validate the format of ip addresses using Java Regular Expression. The basic format of ip addresses format policy is: It must start with a number from 0 – 255. It must be followed a dot This pattern has to repeat for 4 times (eliminating the last dot…) ...
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 »Validate Password with Java Regular Expression example
In the previous tutorial on username validation we explained why input validation is important for your application’s security and data consistency. For our passwords we are going to implement a strict policy about their format. We want our passwords to : Be between 8 and 40 characters long Contain at least one digit. Contain at least one lower case character. ...
Read More »