[sf-perl] regex problem: append path only if not in list already

Joseph Brenner doomvox at gmail.com
Tue Mar 2 15:55:17 PST 2021


> I added a few more test cases to pcre_regex_to_append_path_non_redundantly.t, all of which your edit passes.

And the new test cases showed up as a merge conflict, which is cool.

I was afraid that my hacks that auto-commit and push my saves to the
"raku-study" files would get confused by someone else making changes,
but all is well.

> And thanks for the commented "/x" version.

Sure.  The only way to do it, if you ask me... (I find that perl-hater
types never seem to have heard of /x... not to mention "use strict".)

> Indeed the "\s*" parts are not needed

Yes, but that's more of a nit that anything.  They don't cause any
problems, either  (and actually, I don't know the precise rules are
about what you can encounter in these files).



On 3/2/21, yary <not.com at gmail.com> wrote:
> I added a few more test cases
> to pcre_regex_to_append_path_non_redundantly.t, all of which your edit
> passes. Congrats! And thanks for the commented "/x" version. Indeed the
> "\s*" parts are not needed, I was guessing that the directories had
> optional whitespace around the separating colons. And maybe if I had
> started the task with the commented-extended-regex syntax, I would have
> caught the error!
>
> Odd, I didn't keep the window I tried out my answers in, and there's
> something in my memory that isn't in the solution I posted- I thought I
> explicitly matched the "secure_path" part on the left, which the "real
> world" use-case needs.
>
> -y
>
>
> On Mon, Mar 1, 2021 at 9:59 PM Joseph Brenner <doomvox at gmail.com> wrote:
>
>> Yary:
>>
>> I really like your solution to Lambert's problem.  That idiom of
>> using \K with a negative lookahead is a new one on me.
>>
>> I checked it against a few cases though, and I think it fails if
>> the path is already there in the *first* position.  I tweaked it
>> a bit and got an alternate version that deals with that:
>>
>>
>> https://github.com/doomvox/raku-study/blob/main/bin/2021feb28/pcre_regex_to_append_path_non_redundantly.t
>>
>


More information about the SanFrancisco-pm mailing list