Home » Core Java » util » regex » Page 7

regex

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 »