ambe5960
ambe5960

Reputation: 2000

regex match on words that start with percent

So I have a regex that matches well for any new word in a text box:

return string.substring(0, area.selectionStart).match(/[\wäöüÄÖÜß]+$/);

but I now want to match only when preceded by a '%' symbol, and I don't want to include the % in the match. This is the only condition I want to add everything else works exactly as it should.

I have tried just about everything I can find, but I think I am over complicating it with crazy regEx patterns...

Sincere thanks for any help. It is greatly appreciated.

Upvotes: 0

Views: 424

Answers (1)

vks
vks

Reputation: 67978

%([\wäöüÄÖÜß]+)\b

You use can this and grab the capture or group

Upvotes: 2

Related Questions