0

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.

Tushar
  • 82,599
  • 19
  • 151
  • 169
ambe5960
  • 1,678
  • 1
  • 16
  • 40
  • You will have to include it in the match (as there is no look-behind in JS regex), but use a capturing group with the rest and use the captured text. – Wiktor Stribiżew Oct 20 '15 at 08:56

1 Answers1

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

You use can this and grab the capture or group

vks
  • 65,133
  • 10
  • 87
  • 119
  • @ambe5960 http://stackoverflow.com/questions/432493/how-do-you-access-the-matched-groups-in-a-javascript-regular-expression – vks Oct 20 '15 at 09:16