0

I am working on a presentation regarding Regular Expressions. While trying to break down the expression for an Internet Email Address I have figured out what most of it is aside from the single quote ('). Any assistance would be greatly appreciated. The expression is as follows.

\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
arshajii
  • 127,459
  • 24
  • 238
  • 287
Tom
  • 11
  • 2

3 Answers3

0

' has no special meaning. The regular expression just says that single quotes can be in a valid e-mail address's username, so as long as they come after at least one word character and before at least one word character. For example this is a valid address, according to this regex: a'b'c@xyz.com.

arshajii
  • 127,459
  • 24
  • 238
  • 287
0

This expression does not correspond very well to the actual address specification, but it is true that ' is just an ordinary allowed character in the local part of an email address, and that's presumably why the RE includes it.

In fact, ' can begin or end an address so it's incorrect for that RE to insist that it appear only within the local part. OTOH, . cannot begin or end the local part, so it's somewhat correct that the RE insists it be surrounded by word characters.

(A fairly easy-to-read informational RFC that describes address syntax is RFC 3696.)

Community
  • 1
  • 1
DigitalRoss
  • 143,651
  • 25
  • 248
  • 329
0

Anything inside of the brackets is literally allowed, so they're literally accepting an apostrophe for cases where you would have a name like:

c.o'neil@somewebsite.com
AbsoluteƵERØ
  • 7,816
  • 2
  • 24
  • 35