Home » Core Java » util » regex

regex

Groovy Regex Example

In this example I will show you how to use regular expressions in Groovy. 1. Groovy and Regular Expressions Groovy is one of the most commonly used JVM languages and regular expressions (or simply regex) as a powerful technique to search and manipulate texts have been around us for more than a half century. As most of the languages Java ...

Read More »

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 »

java.util.regex.PatternSyntaxException Example

In this example we will discuss about java.util.regex.PatternSyntaxException. This exception is thrown when a regex (a regular exception) pattern is not correct, i.e. has syntax errors. The PatternSyntaxException extends IllegalArgumentException, which means that an argument passed to a method is illegal or inappropriate. Just like IllegalArgumentException, PatternSyntaxException is a runtime exception (indirect subclass of RuntimeException). This means that the try-catch ...

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 »