user1858261
user1858261

Reputation: 71

Filtering periods out of email addresses with regex

I need to clean a set of gmail addresses that are functionally equivalent using a regex. You may know of the gmail hack where "brunette.thomas@gmail" is treated by gmail as "brunetteandrew@gmail". People are entering multiple entries in a sweepstakes by adding periods to their email address.

I need to filter these down to just the alpha component of the email address, ie., turn:

[email protected]

into:

[email protected]

regardless of the number of periods.

Can anyone help me with this?

Upvotes: 0

Views: 132

Answers (1)

Amadan
Amadan

Reputation: 198388

You can use this to match all periods before the at-sign:

\.(?=.*@)

Then you can just globally replace it with null-string. This will only work on regexp dialects that support lookahead (you haven't stated which dialect you're using).

Upvotes: 2

Related Questions