kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #35726
Re: RegEx help
I ended up changing it as little as possible and testing it with https://regex101.com <https://regex101.com/>. I’m getting the distinct impression that if I went beyond that I’d risk shooting myself in the foot. ;)
> On 6 May 2018, at 06:19, Tiger12506 <tiger12506@xxxxxxxxx> wrote:
>
> No, '?' also means zero-or-one in RegEx syntax, it's just that it *also* happens to mean "make the previous quantity modifier non-greedy" if there is a previous quantity modifier. Notice the double-question mark regex in the documentation quote previously pasted. That one means make the zero-or-one quantifier non-greedy.
>
> On 5/5/2018 5:58 PM, Jeff Young wrote:
>> Ahhh… I’m mixing up XPath and RegEx syntax. ‘?’ is zero-or-one in XPath, not RegEx.
>>
>> Thanks Shiv & Thomas.
>>
>> Cheers,
>> Jeff
>>
>>
>>> On 5 May 2018, at 15:37, Shivpratap Chauhan <shivmsit@xxxxxxxxx <mailto:shivmsit@xxxxxxxxx>> wrote:
>>>
>>> According to documentation at http://docs.wxwidgets.org/3.0/overview_resyntax.html <http://docs.wxwidgets.org/3.0/overview_resyntax.html>
>>>
>>> *? +? ?? {m}? {m,}? {m,n}? Non-greedy quantifiers, which match the same possibilities, but prefer the smallest number rather than the largest number of matches (see Matching <http://docs.wxwidgets.org/3.0/overview_resyntax.html#overview_resyntax_matching>).
>>> There seems to be difference greedy vs non-greedy quantifiers!
>>>
>>>
>>> Thanks,
>>> Shiv
>>>
>>>
>>>
>>> On Sat, May 5, 2018 at 6:49 PM, Jeff Young <jeff@xxxxxxxxx <mailto:jeff@xxxxxxxxx>> wrote:
>>> We have a couple of regular expressions of the form:
>>>
>>> wxRegEx re( ".*?\\$\\{(.+?)\\}.*?", wxRE_ADVANCED );
>>>
>>> Now perhaps I’m too old to remember this stuff correctly, but .*? is redundant, isn’t it?
>>>
>>> And shouldn’t .+? just be .*? (And for that matter, shouldn’t it really be [^}]*?)
>>>
>>> Thanks,
>>> Jeff.
>>>
>>>
>>> Note that I’m looking at this because it needs to check for both ${…} and $(…) formatted envvars, which I think boils down to:
>>>
>>> .*(\\$\\{([^}]*)\\})|(\\$\\(([^)]*)\\)).*
>>>
>>> _______________________________________________
>>> Mailing list: https://launchpad.net/~kicad-developers <https://launchpad.net/~kicad-developers>
>>> Post to : kicad-developers@xxxxxxxxxxxxxxxxxxx <mailto:kicad-developers@xxxxxxxxxxxxxxxxxxx>
>>> Unsubscribe : https://launchpad.net/~kicad-developers <https://launchpad.net/~kicad-developers>
>>> More help : https://help.launchpad.net/ListHelp <https://help.launchpad.net/ListHelp>
>>>
>>>
>>
>>
>>
>> _______________________________________________
>> Mailing list: https://launchpad.net/~kicad-developers <https://launchpad.net/~kicad-developers>
>> Post to : kicad-developers@xxxxxxxxxxxxxxxxxxx <mailto:kicad-developers@xxxxxxxxxxxxxxxxxxx>
>> Unsubscribe : https://launchpad.net/~kicad-developers <https://launchpad.net/~kicad-developers>
>> More help : https://help.launchpad.net/ListHelp <https://help.launchpad.net/ListHelp>
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help : https://help.launchpad.net/ListHelp
References