Reputation: 71
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:
into:
regardless of the number of periods.
Can anyone help me with this?
Upvotes: 0
Views: 132
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