Home » Core Java » util » Page 35

util

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 »