Intro:
I am looking to make a code hinter in Javascript for Vue i18n localizations.
Details:
Using Node readline to read line by line through a Vue file I want to find one pattern using REGEX (of the many patterns I am looking for) which story-wise is as follows:
For a single string,
find any amount of whitespace (spaces or indents)
PLUS
exactly one closing parenthesis
PLUS
exactly one space (for now, this might change)
PLUS (tricky part, bare with me)
any amount of characters, numbers, or special characters except {{$t('[anything here]'}} or {{ $t('[anything here]' }} or if there is nothing after the closing parenthesis altogether this line would fail to match the pattern.
1 | )
2 | )
3 | ) {
4 | ) {{
5 | ) Cancel
6 | ) .[];\`\'.;l][
7 | ) {{ $t('common.cancel') }}
8 | ) {{$t('common.cancel')}}
Lines 1-2 and lines 7-8 should not match. Only lines 3-6 should match.
Attempted Solution:
So far my REGEX pattern is this:
\s+\)\s{1}(.*)
which does not match Lines 1 and 2 (good thing) because of the lack of a single whitespace after the closing parenthesis.
Problem:
It allows Lines 7 and 8 to pass. I can't figure out how to say anything is allowed BUT the three exception scenarios mentioned in the story of what I am trying to achieve.
My brain now:
Thinking baby steps, I want to negate a {
after the single whitespace portion. If I try \s+\)\s{1}(.*)[^\{]
, the not block would negate any of the lines with an opening curly bracket from passing the match. But that's not the case because I am assuming the (.*)
portion renders the negate block useless. Can't seem to even make this baby step. Please help.