Regex to match string ending with string or nothing
javascript, regex
Solution
Change your regex to:
/(?:\/\w*)*(?=(?:%\w{2,})|[\s/]|$)/;
Since you don't have newline `\n` at the end of your inputs. Just end of input anchor `$` will do the job.
Problem
I want to match strings ending with javascript encoded characters (%20, %u200E, etc) or end of line. I've got this regex: `(/\w*?)*(?=(%\w{2,}|[\s/]))` which matches `/text` part in these: /text /text /text%20 /text%u200E But doesn't matches anything in this: `/text` (no character at end, not even new line)