Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!

 

1. JPA Mini Book

2. JVM Troubleshooting Guide

3. JUnit Tutorial for Unit Testing

4. Java Annotations Tutorial

5. Java Interview Questions

 

and many more ....

 

 

Matcher group example

This is an example of how to use Matcher.group(int group) API method to get the input subsequence captured by the given group during the previous match operation. Grouping with a Matcher implies that you should: Compile a String regular expression to a Pattern, using compile(String regex) API method of Pattern. Use matcher(CharSequence input) API method of Pattern to create a ...

Read More »

Match address using regular expressions

This is an example of how to match an address using regular expressions. We have created a method boolean isValidAddr(String addr) and used it to match some addresses to a specified pattern. The method is described below: The method reads a String address and returns true if a specified pattern matches the address and false otherwise. It has a a ...

Read More »

Regular expressions for IP v4 and IP v6 addresses

In this example we shall show you how to check if an address is an IPv4 or IPv6 address, using regular expressions. To check an address with regular expressions we have created three different patterns, as described in the steps below: The first pattern is creating by compiling a String regular expression that describes the IPv4 address, using compile(String regex) ...

Read More »

Swing GUI application for regular expression testing

This is an example of how to create a Swing GUI application for regular expression testing. The application creates a window that reads a pattern and a String and checks if the String matches the pattern and how many times the pattern appears in the String. The steps to create such an application are described below: Class GuiDemo extends the ...

Read More »

Pattern matcher example – Part 2

This is an example of how to use a Pattern Matcher to match an input String with a specified pattern. Matching a String to a pattern with a Matcher implies that you should: Compile a String regular expression to a Pattern, using compile(String regex) API method of Pattern. Use matcher(CharSequence input) API method of Pattern to create a Matcher that will ...

Read More »

Pattern matcher example

In this example we shall show you how to use a Matcher and a Pattern in Java to match an input String to a specified pattern. To use a matcher and a pattern one should perform the following steps: Compile a String regular expression to a Pattern, using compile(String regex) API method of Pattern. Use matcher(CharSequence input) API method of ...

Read More »

Regular expression match group example

This is an example of how to use a regular expression match group. Using a regular expression to group matches of a String with a pattern implies that you should: Compile a String regular expression to a Pattern, using compile(String regex) API method of Pattern. Use matcher(CharSequence input) API method of Pattern to create a Matcher that will match the given ...

Read More »

Split a string into an array by regular expressions

This is an example of how to split a string into an array by regular expressions. Splitting a string by regular expressions implies that you should: Compile a String regular expression to a Pattern, using compile(String regex) API method of Pattern. Split the given input sequence around matches of this pattern, using split(CharSequence input) API method of Pattern. The result of ...

Read More »

Case control example

In this example we shall show you how to handle a case control using a class with a regular expression. To use a regular expression to check on a case one should perform the following steps: Compile a String regular expression to a Pattern, using compile(String regex, int flags) API method of Pattern, with case-insensitive matching. Compile the same regular expression ...

Read More »

String.matches method example

With this example we shall show you how to use String.matches(String regex) API method to check if a given String matches a given regular expression. Checking if a String matches a regular expression implies that you should: Create a new String pattern, that is a regular expression. Use matches(String regex) API method of String to check if the String matches ...

Read More »