[Chicago-talk] Help with regex

Daniel Rench drench at gmail.com
Sat Jan 20 12:48:18 PST 2024


You’re close. I tweaked it slightly, and it works for me:

%  perl -e 'my $em = "smagill\@abcco.com1/15/1998"; $em =~
s#[\d/]+$##; print "EMAIL: $em\n";'
EMAIL: smagill at abcco.com

The concept is the same: work from the end, not the start of the string. I
removed the parens since you don’t need them, and changed the / to # to
avoid “leaning toothpicks” \/.


On Sat, Jan 20, 2024 at 2:41 PM Richard Reina <richard at rushlogistics.com>
wrote:

> Mike, Thanks for the quick reply but
>
> perl -e 'my $em = "smagill\@abcco.com1/15/1998"; my $em =~ s/([\d\\])+$//;
> print "EMAIL: $em\n";'
>
>
>
>
> gives me:
>
> Unmatched ( in regex; marked by <-- HERE in m/( <-- HERE [\d\\]+$/ at -e
> line 1.
>
> Tried adding a ) after +$ but that just gives me an empty string for $em.
> Maybe I'm doing something wrong?
>
>
>
> On Sat, 20 Jan 2024 14:28:52 -0600, Mike Raffety <
> MikeRaffety at earthlink.net> wrote:
>
> s/([\d\\]+$//;
>
> Richard Reina wrote on 1/20/2024 2:24 PM:
> > Good day fellow perl mongers,
> >
> > I have a bunch of email addresses that have been corrupted with digits
> (mostly dates) stuck to the end. such as smagill at abcco.com12/19/1198 I am
> trying to figure out what kind of regex I can use to remove the numbers and
> recover the pure email address. I initially thought of something like
> >
> > $email =~ s/^\\D*\\d+//;
> >
> > but that didn't work and I quickly realized that even if it had it would
> fail if there were a digit in the email address.
> >
> > Any help would be greatly appreciated.
> >
> > Richard
> > _______________________________________________
> > Chicago-talk mailing list
> > Chicago-talk at pm.org
> > https://mail.pm.org/mailman/listinfo/chicago-talk
>
> _______________________________________________
> Chicago-talk mailing list
> Chicago-talk at pm.org
> https://mail.pm.org/mailman/listinfo/chicago-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/chicago-talk/attachments/20240120/83d5ae95/attachment.html>


More information about the Chicago-talk mailing list