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 ....

 

 

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 »

List files with regular expression filtering

This is an example of how to list files using regular expression filtering. In order to list Files using regular expressions to filter them we have set the example below: Class DirFilter implements the FilenameFilter. It has a Pattern that is initialized by compiling a String regular expression to a Pattern, using compile(String regex) API method of Pattern. It also has a ...

Read More »

Remove line termination characters from string

In this example we shall show you how to remove line termination characters from a String, using regular expressions. To remove line termination characters from a String one should perform the following steps: Create a String that contains a line separator as specified by the System.getProperty(String key) API method. Compile a String regular expression to a Pattern, using compile(String regex) ...

Read More »

Compile Reg Ex pattern with multiple flags

With this example we shall show you how to compile regular expression to a Pattern with multiple flags. Compiling a regular expression to a Pattern with multiple flags 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 ...

Read More »

Greedy and non-greedy Reg Ex matching

This is an example of how to use greedy and non-greedy regular expression matching. Greedy matching means that the expression will match as large a group as possible, while non-greedy means it will match the smallest group possible. Matching with greedy and non-greedy regular expressions implies that you should: Compile a String regular expression to a Pattern, using compile(String regex) API ...

Read More »

Check if a string matches a Pattern

In this example we shall show you how to check if a String matches a Pattern. To check if a String matches 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 Pattern to create a Matcher that will match the given ...

Read More »

Get package name

This is an example of how to get the package name of a class. Getting the package name of a class implies that you should: Create a new object of the class. Use getClass() API method of Object for the class to get the runtime class of this object. The returned Class object is the object that is locked by static ...

Read More »