'|'allows you to combine multiple expressions.
Ex:
(fir|la|be)st match strings first, last, best
Run the harness program.
Sample
Output
Enter Regular Expression
(fir|la|be)st
Enter the string
I am always last
I found the text last starting at index 12 Ending at
index 16
Enter the string
I love best among best
I found the text best starting at index 7 Ending at
index 11
I found the text best starting at index 18 Ending at
index 22
Enter the string
first come first serve
I found the text first starting at index 0 Ending at
index 5
I found the text first starting at index 11 Ending at
index 16
Enter the string
first come last serve
I found the text first starting at index 0 Ending at
index 5
I found the text last starting at index 11 Ending at
index 15
Note:
Use this program to run above sample
No comments:
Post a Comment