[tpm] Weird Regex Replace Problem

tpm.ats at spamgourmet.com tpm.ats at spamgourmet.com
Thu Sep 10 21:16:08 PDT 2020


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

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


More information about the toronto-pm mailing list