Carret
(^) and dollar($) represents start and end of a line respectively.
Regular
expression '^cat' matches any line, that starts with string 'cat'.
Sample
runs of Harness program.
Enter
Regular Expression
^cat
Enter
the string
cat
I
found the text cat starting at index 0 Ending at index 3
Enter
the string
cat
is a cat
I
found the text cat starting at index 0 Ending at index 3
Enter
the string
cat
is animal
I
found the text cat starting at index 0 Ending at index 3
Enter
the string
cattering
I
found the text cat starting at index 0 Ending at index 3
Enter
the string
mcat
java.lang.IllegalStateException:
No match found
No comments:
Post a Comment