0

Here is the regex that I have:

\Ame\..*$

And I want it to match on:

me.com
me.ca
[email protected]
[email protected]

It also must not match on:

[email protected]
me.you@foo

Currently it only matches the domain and not the full email.

I am using ruby for this.

I have been using http://rubular.com/ to try and solve this.

1
  • 1
    Check out Friedl'd Mastering regular expressions, it contains a regular expression for email addresses (it is several pages long!). Commented Mar 1, 2014 at 23:41

1 Answer 1

1

The following works, if I understand your requirements correctly:

\bme\.[^.@]*\z

Explanation:

\b     # Match the start of a word
me     # Match "me"
\.     # Match "."
[^.@]* # Match any string unless it contains a "." or a "@"
\z     # Match the end of the string 

(I used \z instead of $ as I did on the Rubular example because that also matches the end of a line).

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

1 Comment

can you also make it not match me.you@foo

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.