@Sean-Voltaire said in How to highlight numbers WITHIN words:
I have already tried toggling the setting “Match whole words only”
Preferences>Highlighting>Smart Highlighting only affects what is shown when you manually select a piece of text: if you select 314159 here, then it will look like:
Any
Whole Words Only
0110005c-2c89-4945-afbf-cba3a4e8c751-image.png
5a9ee64c-1b2a-4aa4-aad4-322950bf95aa-image.png
But that will only show you exactly the digits that are currently selected – so it finds the digits of pi, but not the digits of e, since the digits of pi are the ones I had selected.
That option does not affect UDLs.
I wasn’t sure if that was tried as a way to change the behavior of the UDL, or if that “match whole word only” was meant to affect something else other than manually selecting text and having it highlight all other text that matches the selection.
If you couldn’t think of other ways to manually select/mark digits: use the Search > Mark (Ctrl+M) and use a regular expression to manually mark all strings of digits.
04917b6d-291b-4a74-9aa7-7dd2f9395ae8-image.png
But given your focus on UDL in the rest of your question, I wonder if you are really just trying to change UDL behavior. You cannot do that with any of the options in the Preferences dialog; UDL is controlled via the UDL dialog/panel and that’s it.
As far as UDL syntax goes: no, there is no ((SPACE)). ((EOL)) is the only fancy escape… well, except for enclosing a term in quotes: "key word" will match key word but not key other word
cf28a316-8c9f-4b96-9138-77011b395f0d-image.png
The quote-around-spaces works for keywords and folding-in-code-2, but in my experiments today, I couldn’t get it to work in folding-in-code-1 or comment-line or operators or delimiters. So that might work for your ((SPACE)) desire, in certain circumstances.
If you’re really looking to highlight extra numbers that are in weird situations and would like to be able to use a regex but otherwise treat it as a UDL, you can use @Ekopalypse’s Enhance Any Lexer. For example, if I have a UDL called “voltaire” which uses an aqua-like color similar to what you have for its “number style”, and in Enhance Any Lexer, set
[voltaire]
0xFFFF00 = (?<=[\l\u_])\d+|\d+(?=[\l\u_])
which will set digits to bright cyan if they have upper or lowercase or underscore to the left or right; otherwise, if the UDL thinks of it as a “word” of numbers (spaces or operators to either side), then the UDL will highlight them with the aqua.
adc84e21-736b-4a56-b90d-d31c8dc9d19d-image.png