by, 04-26-2012 at 06:46 PM (416 Views)
Basic pattern matching form that is being supported by API is string literal match. E.g, when regular expression and input string is foo, matching succeeds as strings are same. Test harness could be used to try it.
Enter regex: foo
Enter “input string” for search: foo
Text foo is found that starts at index 0, & ends at index 3.
Match was successful. It shall be noted that when input strings are three characters longer then starting index is zero and ending index is three. Beginning index include ranges and end index are exclusive of it, as following:
Every character that is present in string is present in own clee along with index that positions pointing b/w every cell. Foo string begins at o and ends at 3 index even characters just occupy zero, one and two.
Overlap will be noticed along with subsequent match; Next match’s start index is same as previous match’s end index:
Enter regex i.e. foo
Enter “input string” for search i.e. foofoofoo
Text foo is found that starts at index zero & ends at index three.
Text foo is found that starts at index three & ends at index six.
Text foo is found that starts at index six & ends at index nine.