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

yary not.com at gmail.com
Tue Mar 2 07:37:44 PST 2021


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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/sanfrancisco-pm/attachments/20210302/9fa8c62d/attachment-0001.html>


More information about the SanFrancisco-pm mailing list