Reputation: 6039
I am trying to get the tokens in the message text so that they can be string replaced by the actual values. My text is
Hello &worls nice &to & Here &ok.
The expression (&\w+?)\W gives me
worls<whitespace>
to<whitespace>
ok.
However I need to exclude the last letter i.e whitespace or period
Testing link http://regexr.com?33nrg
Upvotes: 0
Views: 1700
Reputation: 21507
Test for word boundary (\b
) instead of looking for non-word character \W
.
Also it would be fine to learn how to work with regexp match groups in your tool or language of choice, so you can retrieve and use a substring matching any subexpression.
Upvotes: 2