Particular question about a RegEx

Just starting out? Need help? Post your questions and find answers here.
boddhi
Enthusiast
Enthusiast
Posts: 524
Joined: Mon Nov 15, 2010 9:53 pm

Re: Particular question about a RegEx

Post 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! :mrgreen:
I will study and take into consideration all your comments. . Thanks anyway :wink:
AZJIO wrote: why put part of the name in a group?

Code: Select all

(\w)* = \w*
I'll review my code later to answer :mrgreen:
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. :wink:
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...
boddhi
Enthusiast
Enthusiast
Posts: 524
Joined: Mon Nov 15, 2010 9:53 pm

Re: Particular question about a RegEx

Post 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. :mrgreen: :lol:
You're right and I'm going to “correct” it. :wink:
(\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:

Code: Select all

ProcedureCCDLL
ProcedureDLLL
Nobody is perfect! :mrgreen: :lol: :wink:

Thanks again :wink:
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...
AZJIO
Addict
Addict
Posts: 2191
Joined: Sun May 14, 2017 1:48 am

Re: Particular question about a RegEx

Post 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
boddhi
Enthusiast
Enthusiast
Posts: 524
Joined: Mon Nov 15, 2010 9:53 pm

Re: Particular question about a RegEx

Post by boddhi »

AZJIO wrote: 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
Your're absolutely right! but only if code has been previously checked/compilated, not if it has been only saved.
Image
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...
AZJIO
Addict
Addict
Posts: 2191
Joined: Sun May 14, 2017 1:48 am

Re: Particular question about a RegEx

Post 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
boddhi
Enthusiast
Enthusiast
Posts: 524
Joined: Mon Nov 15, 2010 9:53 pm

Re: Particular question about a RegEx

Post by boddhi »

Hi,

I know it :wink: 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.
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...
Post Reply