Page 2 of 2
Re: Particular question about a RegEx
Posted: Mon May 27, 2024 9:15 am
by boddhi
AZJIO wrote:
The "OR" group is used if at least one element is more than one character
[...]
I'm not a great specialist of RegEx and some simplifications are surely possible!
I will study and take into consideration all your comments. . Thanks anyway
AZJIO wrote:
why put part of the name in a group?
I'll review my code later to answer
AZJIO wrote:
This is the wrong way to encode. I don't think anyone will write a program in one line. Unless someone codes specifically to make your program unable to analyze code, I don’t see any other reason to write code that way.
I know and I don't do like that too but, as I say, PB authorizes this syntax and I've used Debug as an example, but it could have been any other instruction set with a semicolon inside.
Piero wrote:
Did you see my post about "exclusive regexps"?
I'll take a look at it.

Re: Particular question about a RegEx
Posted: Mon May 27, 2024 10:08 am
by boddhi
AZJIO wrote:
{1} ↣ there is no need to write this, it is by default
(a|b|c|d|f|i|l|q|s|u|w) = [abcdfilqsuw] ↣ The "OR" group is used if at least one element is more than one character
(\w)* = \w* ↣ why put part of the name in a group?
In French, we have a maxim: "Deux précautions valent mieux qu'une" ("Two precautions are better than one”) and we sometimes tend to overdo it.
You're right and I'm going to “correct” it.
(\v+|(?<!:):(?!:))[\h;]*(?:Procedure[CDL$]{0,5}?(?:\h*\.[abcdfilqsuw])?\h+\K)[A-Za-z_]\w*\h*(?=\()
But here, you're wrong because it accepts codes like:
Nobody is perfect!
Thanks again

Re: Particular question about a RegEx
Posted: Mon May 27, 2024 10:33 am
by AZJIO
boddhi wrote: Mon May 27, 2024 10:08 am
Nobody is perfect!
This was intended, because it would never occur to anyone to play with these symbols while making non-working code.
https://www.purebasic.fr/english/viewto ... 52#p535552
Re: Particular question about a RegEx
Posted: Mon May 27, 2024 10:43 am
by boddhi
Your're absolutely right! but only if code has been previously checked/compilated, not if it has been only saved.

Re: Particular question about a RegEx
Posted: Mon May 27, 2024 12:38 pm
by AZJIO
boddhi wrote: Sun May 26, 2024 7:44 am
But, because PB allows this kind of syntax, how do you ensure that a case like the following will be accepted?
Are you aware of the existence of the PureBasic\SDK\Syntax Highlighting\SyntaxHighlighting.dll?
This file will never go wrong when searching for keywords, since it is an official code analyzer. Once you have received the Procedure keyword, you read subsequent data until the end of the line or until the comment. You will have a 100% guarantee.
https://www.purebasic.fr/english/search ... mit=Search
By the way, pay attention to the
FindAllReferences tool
Re: Particular question about a RegEx
Posted: Wed May 29, 2024 1:02 am
by boddhi
Hi,
I know it

I used it a little bit in a tool... but I've just skimmed it, I don't know all its features.
I'll take a look.
Thanks.