Presentation is loading. Please wait.

Presentation is loading. Please wait.

Matcher functions boolean find() Attempts to find the next subsequence of the input sequence that matches the pattern. boolean lookingAt() Attempts to.

Similar presentations


Presentation on theme: "Matcher functions boolean find() Attempts to find the next subsequence of the input sequence that matches the pattern. boolean lookingAt() Attempts to."— Presentation transcript:

1 Matcher functions boolean find() Attempts to find the next subsequence of the input sequence that matches the pattern. boolean lookingAt() Attempts to match the input sequence, starting at the beginning, against the pattern. boolean matches() Attempts to match the entire input sequence against the pattern.

2 Some more Matcher function
Pattern pattern() Returns the pattern that is interpreted by this matcher. String replaceAll(String replacement) Replaces every subsequence of the input that matches the pattern with the given string. String replaceFirst(String replacement) Replaces the first subsequence of the input that matches the pattern with the given string.

3 Rules for writing Regex in Java
\w ->alphabetical character [a-zA-Z] \W -> any non-alphabetical character \d -> digit [0-9] \D -> non digit \s -> space character \S -> non-space character \b -> word boundary

4 Specifying the limit of occurence
\\d? -> 0 or 1 times \\d* -> 0 or more times \\d+ ->1 or more times \\d{n,m} -> minimum n times and maximum m times

5 Write Regular Expressions
For identifying all addresses of the form For identifying telephone number as per Indian standard like (city code) number Example (022) For representing string containing at least 4 a’s For representing strings ending with (-ing, -ment, -tion, -es)

6 References URL: http://www.regular-expressions.info/tutorial.html


Download ppt "Matcher functions boolean find() Attempts to find the next subsequence of the input sequence that matches the pattern. boolean lookingAt() Attempts to."

Similar presentations


Ads by Google