I need to select some text between % signs where there is not white space between 2 %.
This should match:
%link%
This shouldn't:
%my link%
This easy regex would do the trick:
/%\S*%/g
But there is a catch: I can add a prefix: % and a suffix: % but the regex must contain this between these: (.+?) (it's a third party script).
So this is the regex I need to adjust:
/%(.+?)%/
Because of "(.+?)" I need a workaround, any idea?
UPDATE: All of these are true for a perfect regex:
regex = /%(.+?)%/g // default regex which allows spaces so it's not good
regex.test('%link%')
regex.test('%my link%') === false
regex.toString().includes('(.+?)')