I am new to regex and need to parse a comma-separated input of email address extensions (everything after the @ symbol). Example:
foo.bar,foo.bar.baz,foo-bar.baz
I know that there are no whitespaces in the string. Also. following is the regex I want to use for just a single email extension:
/[a-z\d\-.]+\.[a-z]+\z/i
How do I modify the regex in Ruby to work with multiple extensions which are comma separated?
Thanks!
You’re probably better of splitting the list into components and then checking each component:
That may not be a one-liner but it will probably be a lot easier to understand six months down the road (unless, of course, your regex-fu gets stronger).