I trying to write a regular expression that would match a particular word and continue matching until a period is encountered. For example:
Text:
Which Have Never Won Two Races Other Than Maiden, Claiming, Or Starter Or Which Have Never Won Three Races Or Optional Claiming Price Of $25,000. Three Year Olds, 118 Lbs.; Older, 123 Lbs. Non-winners of $24,000 since March 9 Allowed 2 Lbs.
Desired Match:
Which Have Never Won Two Races Other Than Maiden, Claiming, Or Starter Or Which Have Never Won Three Races Or Optional Claiming Price Of $25,000.
Regular Expression:
(?<Match1>Which\s[a-zA-Z]*[.])
Unfortunately my proposed expression captures all of the text and seems to extend to the last period instead of the first.`
It is actually pretty simple. Use
[^.]*to match all characters up but not including to the next.and surround your desired word by\bboundaries. I appended the final.as\.assuming you want to include that in the matched output.