[tpm] Weird Regex Replace Problem

Antonio Sun tpm.ats at spamgourmet.com
Fri Sep 11 13:48:17 PDT 2020


On Fri, Sep 11, 2020 at 2:12 AM Shlomi Fish wrote:
>
> Hi Antonio,
>
> On Fri, 11 Sep 2020 00:16:08 -0400
> tpm.ats at spamgourmet.com wrote:
>
> > So weird. Maybe it is the long 15hr working effect, but I just can't
> > figure it out myself now.
> >
> > Please take a look at
> >
> > https://regex101.com/r/Hb7gjk/1
> >
> > That Regex replace would work for Perl as well, right?
> >
> > BTW, are there any online Regex replace trial sites like above that
> > work with Perl's Regex?
> >
> > Anyway, I can't get it working, but at least I get this works, kind of:
> >
> > perl -i.bak -p0777e 's/^var (.*?Infos) = .*?data: ([^\n]+),/var $1 =
> > {\n        data: $1_data,/gms' myfile.js
> >
> > The file (first 250,000 characters) is available at
> > http://dpaste.com/8L2VYU295
> >
> > My replace result is at:
> > http://dpaste.com/9UQF6JE43
> >
> > What's weird is that, it almost works, but there is one replacement,
> > the one on line 410, took away the whole following section, bleeding
> > over to the next match. But others are just fine!!
> >
> > Please
> >
> > - See if you get the same result as mine using my "working" Perl command.
> > - Explain why the one at https://regex101.com/r/Hb7gjk/1 is failing for Perl.
> > - Preferably make the one at https://regex101.com/r/Hb7gjk/1 work for
> > Perl, as close as possible
> > - Recommend trial sites like above that work with Perl's Regex
>
> Off the top of my head:
>
> 1. https://perl.bot/ - can be used to run bona fide Perl code as well as bash
> code calling perl. Open source.
>
> 2. https://ideone.com/ - supports several languages including Perl.
>
> 3. https://travis-ci.org/ - supports running tests and arbitrary code from
> github/etc. repositories
>
> 4. https://en.wikipedia.org/wiki/AppVeyor - a similar service.
>
> For more information, see this guide I co-wrote:
> https://github.com/shlomif/how-to-share-code-online .
>
> Hope that helps.
>
> >
> > Thanks a lot!
> >
> > Antonio
> >
> > PS. please don't directly reply to me as my this email address is only
> > good for receiving emails from toronto-pm at pm.org.
> >
> > PPS. my env:
> >
> > $ perl -v | head -3
> >
> > This is perl 5, version 30, subversion 0 (v5.30.0) built for
> > x86_64-linux-gnu-thread-multi
> > (with 48 registered patches, see perl -V for more detail)
> >
> > $ uname -rm
> > 4.19.76-linuxkit x86_64
> >
> > $ lsb_release -a
> > No LSB modules are available.
> > Distributor ID: Debian
> > Description:    Debian GNU/Linux bullseye/sid
> > Release:        testing
> > Codename:       bullseye
> > _______________________________________________
> > toronto-pm mailing list
> > toronto-pm at pm.org
> > https://mail.pm.org/mailman/listinfo/toronto-pm

Thanks a lot Shlomi for your comprehensive summary!

@Liam, thanks for looking into it. The problem was in fact elsewhere,
check out https://regex101.com/r/o3uVwQ/1/ if you are interested to
find out -- A rather silly one. It was too late last night.

Thanks again.


More information about the toronto-pm mailing list