Scintilla line highlighting

Just starting out? Need help? Post your questions and find answers here.
User avatar
rndrei
Enthusiast
Enthusiast
Posts: 183
Joined: Thu Dec 28, 2023 9:04 pm

Scintilla line highlighting

Post by rndrei »

Please tell Scintilla how to highlight a line with a comment, I found information about highlighting numbers:

Code: Select all

reg() = "\d+"
How can I highlight a line with the "#" symbol?
I couldn't find any information on the Scintilla website...
boddhi
Enthusiast
Enthusiast
Posts: 524
Joined: Mon Nov 15, 2010 9:53 pm

Re: Scintilla line highlighting

Post by boddhi »

rndrei wrote: Please tell Scintilla how to highlight a line with a comment, I found information about highlighting numbers:

Code: Select all

reg() = "\d+"
How can I highlight a line with the "#" symbol?
Assuming your request is for RegEx, a comment example would have been helpful to refine it!
So, exclusively for lines beginning with # :

Code: Select all

reg() = "^#.*"
If my English syntax and lexicon are incorrect, please bear with Google translate and DeepL. They rarely agree with each other!
Except on this sentence...
User avatar
rndrei
Enthusiast
Enthusiast
Posts: 183
Joined: Thu Dec 28, 2023 9:04 pm

Re: Scintilla line highlighting

Post by rndrei »

Yes, thanks, that's what I need
User avatar
rndrei
Enthusiast
Enthusiast
Posts: 183
Joined: Thu Dec 28, 2023 9:04 pm

Re: Scintilla line highlighting

Post by rndrei »

where can I get a complete list of regex codes?
AZJIO
Addict
Addict
Posts: 2223
Joined: Sun May 14, 2017 1:48 am

Re: Scintilla line highlighting

Post by AZJIO »

Google?
https://scite-ru.bitbucket.io/pack/doc/SciTERegEx.html - it's not objective, it's SciTE, not Scintilla

https://azjio.narod.ru/regexp/RegExpEn.htm - This is a PCRE engine, and Scintilla has a very stripped-down engine.

Instead of \b, use "\<" and "\>" (word boundaries). Instead of the range [a-zA-Z]+ you need to use [qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM]+
No forward and backward preview (?<=...) and (?=...)
No OR sign "|" to highlight a set of keywords, you need to specify each one separately
User avatar
rndrei
Enthusiast
Enthusiast
Posts: 183
Joined: Thu Dec 28, 2023 9:04 pm

Re: Scintilla line highlighting

Post by rndrei »

thank you, otherwise I couldn’t find the information :)
User avatar
rndrei
Enthusiast
Enthusiast
Posts: 183
Joined: Thu Dec 28, 2023 9:04 pm

Re: Scintilla line highlighting

Post by rndrei »

I can't figure it out! If two words are needed, then what kind of construction will it be?

Code: Select all

reg()="(text_first|text_second)"
User avatar
Demivec
Addict
Addict
Posts: 4281
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Scintilla line highlighting

Post by Demivec »

rndrei wrote: Mon Sep 30, 2024 7:51 am I can't figure it out! If two words are needed, then what kind of construction will it be?

Code: Select all

reg()="(text_first|text_second)"
Do two separate searches.
User avatar
rndrei
Enthusiast
Enthusiast
Posts: 183
Joined: Thu Dec 28, 2023 9:04 pm

Re: Scintilla line highlighting

Post by rndrei »

I need one search
User avatar
spikey
Enthusiast
Enthusiast
Posts: 778
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: Scintilla line highlighting

Post by spikey »

The solution you presented should work, if you're searching for specific words. What sort of problem were you having? Or what string that you expected to match, didn't?

Can I recommend you bookmark https://regex101.com/. It's a reference site for various flavours of regex, testing sandpit and will even explain and try to debug your regexes too, all in a webpage, for free and you don't even need to sign up... Oh and there's a searchable list of other people's solutions to various problems too.
User avatar
Demivec
Addict
Addict
Posts: 4281
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Scintilla line highlighting

Post by Demivec »

@Spikey: Scintilla's base implementation of regular expressions is simple and limited. For example it doesn't implement the 'I' for matching OR expressions. AZJIO mentioned a few other limitations in his earlier post as well.

https://www.scintilla.org/ScintillaDoc.html#Searching
User avatar
rndrei
Enthusiast
Enthusiast
Posts: 183
Joined: Thu Dec 28, 2023 9:04 pm

Re: Scintilla line highlighting

Post by rndrei »

I can't figure out how to make an exception?
For example, all words except those ending with the symbol ";"
The example does not work:

Code: Select all

regex()\re = "[a-zA-Z](^;)"
User avatar
rndrei
Enthusiast
Enthusiast
Posts: 183
Joined: Thu Dec 28, 2023 9:04 pm

Re: Scintilla line highlighting

Post by rndrei »

Got it! If anyone is interested, it will be like this:

Code: Select all

 regex()\re = "[a-zA-Z]+[;]"
AZJIO
Addict
Addict
Posts: 2223
Joined: Sun May 14, 2017 1:48 am

Re: Scintilla line highlighting

Post by AZJIO »

Code: Select all

[a-zA-Z]++(?!;)
Post Reply