I am reading Boundary Matcher from Oracle Documentation. I understand most of the part, but i am not able to grasp the \b
Boundary Matcher. Here is the example from the documentation.
To check if a pattern begins and ends on a word boundary (as opposed to a substring within a longer string), just use \b on either side; for example, \bdog\b
Enter your regex: \bdog\b Enter input string to search: The dog plays in the yard. I found the text "dog" starting at index 4 and ending at index 7.
Enter your regex: \bdog\b Enter input string to search: The doggie plays in the yard. No match found. To match the expression on a non-word boundary, use \B instead:
Enter your regex: \bdog\B Enter input string to search: The dog plays in the yard. No match found.
Enter your regex: \bdog\B Enter input string to search: The doggie plays in the yard. I found the text "dog" starting at index 4 and ending at index 7.
In short, i am not able to understand the working of \b. Can someone help me describing its usage and help me understand this example.
Thanks