1

I'm trying to match either @ or the string at, like for name@email and nameatemail. I imagine it's something like

regex = '@|at'

or

regex = '@|(at)'

but I just can't find the right syntax.

4
  • 5
    Ummm... you're a bit screwed if someone's called Nathan or Natalie aren't you? :) Commented Jan 15, 2013 at 7:29
  • Ugh, yes. Good point - thanks! Commented Jan 15, 2013 at 7:33
  • @Jon Clements made a good point . for that case, I suggest just keep it for further identification(may be you have a name dictionary in hand) or maintain a list of popular mail service provider , such gmail.com , yahoo.com , then , if you found a string ends with "Nathanatgmail.com", then just translate"atgmail.com" into "@gmail.com" and keep the ”Nathan“ unchanged . Commented Jan 15, 2013 at 8:27
  • 1
    So in essence you're trying to deobfuscate email addresses? Why? Any plans for spamming? Commented Jan 15, 2013 at 8:30

2 Answers 2

2

I suggest you use Kodos to test your regular expressions (it also provides you with Python code for your regex). And this for regular expression info.

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

Comments

0

For your issue both regex works correctly:

match = re.search("@|at", subject)
if match:
    result = match.group()

1 Comment

I didn't realize that it would look at the entire "at", not just the 'a'. You're right! Thanks!

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.