Reputation: 4681
I'm working on a Nano color code for Assembly.
I had simply this (only including eax and ebx as there are dozens of them):
color brightcyan "(eax|ebx)"
However, they may be highlighted in other words such as "Hesitate" where "esi" is colored cyan.
Then I used this:
color brightcyan "(\ |\[|\+|\-|\]\*")(eax|ebx)"
Which works, but turns other sybols cyan when I have them in another color (such as [
). However, I want it to turn blue ONLY if it's NOT surrounded by alphanumeric characters. Any other symbols should not hinder the coloring, nor should they be colored.
Upvotes: 0
Views: 121
Reputation: 3437
You have some options.
The simpelest is to use the word boundary marker \b
.
\b(eax|ebx)\b
Will match eax or ebx only when it forms a whole word. Note that this does not quite match what you ask for, since it looks for a distinction between word and non-word characters, rather than alphanumeric contra non alphanumeric. So my suggestion would not match in the case of "_eax"
Upvotes: 3
Reputation: 46258
Try using word boundaries:
color brightcyan "\b(eax|ebx)\b"
Upvotes: 3
Reputation: 3454
Try "\b(eax|ebx)\b"
. This will only match if it's not surrounded by alphanumeric characters or _
.
Upvotes: 3