Lets say for example I have a note with the following text
<link name="prototype" color="#993333" required="true" />
What I want is for highlighters to only highlight the word prototype.
How would I do this using a custom Highlighter note. Currently I am using
color: bright red
but this is highlighting everything that is within the double quotes. In the example above here is what I get,
which is not what i want
This is what I want
Is this possible?
Thanks in advance
The literal pattern:
Resulting the quotes being highlighted. So you need a ‘positive look-behind’ group before your literal string and a ‘positive look-ahead’ group after your literal string. Thus:
color: bright red
So, ‘prototype’ or ‘Prototype’ are matched but only if proceeded and followed by straight double quotes.
Edit: note the extra regex need to be non-capturing groups to ensure the quotes aren’t coloured.
One other thought. I’m not an expert here, but from what I do know of regex I assume these look-ahead/behind commands are at the more computationally expensive end of regex work. No big deal on a high-end Mac running the highlighter on a few notes. Low end Mac and 100s of such notes—perhaps not. Just something to bear in mind. I’ve learned to remember to consider scale as well as just completing the task at hand.
The above doesn’t imply Tinderbox is slow—it absolutely isn’t!
Awesome… learned something today re: “positive look-behind” and “positive look-ahead”
" from what I do know of regex I assume these look-ahead/behind commands are at the more computationally expensive end of regex work."
No worries. I have a custom Highlighters note with <5 notes attached to it.
Wonderful. So please forgive me what might seem presumptive implied critique.
Not at all, it was a good reminder