1

Im using this currently :

/^(.*)\+(.*)@gmail.com/

(I'm capturing the text before and after the plus sign in a group)

and it works in most cases such as [email protected] but falls down if I try to match say [email protected]

The repeated + signs seem to screw it up.

Any help would be much appreciated.

Thanks

7 Answers 7

5

(.*?)\++(.*?)@gmail.com should work.

Sign up to request clarification or add additional context in comments.

Comments

1

you need to escape the + sign : /^(.+?)\++(.+?)@gmail.com/

EDIT : your post was misformatted : your + is already escaped

Comments

1

You are not properly detecting the +. Use something like this: ^([^+]+)[+]+([^+]+)@gmail.com

Comments

1
[a-zA-Z0-9]{1,}[\+]{0,}[a-zA-Z0-9]{0,}@gmail.com 

Comments

0

You can use [] with ^ (all the chars but...) e.g.

echo '[email protected]' | perl -p -e 's/^([^\+]*)\+(.*)@gmail.com/$1/' 

Comments

0

If you don't care about validating the first portion of the address (prior to any '+') you could go with /^([^+]+)(:?+[^+]*)*@gmail.com/ to just the first part.

You may want to do better validation on that to ensure that it is a "valid" account format, according to whatever rules are set forth by RFC.

edit -- asterisks were making a bold statement.

Comments

0

I think this can be simplified a touch:

IF you know the address you're looking for and want to match your address regardless of whether it has a 'plus' tag on it:

bignev(\+.*)*@gmail.com 

If you only want the ones with the 'plus' tag:

bignev(\+.*)@gmail.com 

If you have your own domain:

bignev(\+.*)*@everton.com 

Or to answer the original post specifically:

.*(\+.*)@gmail.com 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.