· java RegexDemo .*+end "This is the end"
:
uses a possessive quantifier to match all characters followed by end
in This is the end
zero or more times. The following output results:Regex = .*+end
Text = This is the end
end
. In contrast, the greedy quantifier in java RegexDemo .*end "This is the end"
produces a match because it causes a matcher to keep backing off one character at a time until the rightmost end
matches. Boundary matchers
We sometimes want to match patterns at the beginning of lines, at word boundaries, at the end of text, and so on. Accomplish that task with a boundary matcher, a regex construct that identifies a match location. Table 2 presentsPattern
's supported boundary matchers. Table 2. Boundary matchers
|
No comments:
Post a Comment