0

I'm attempting to create a form step where one of the form step items is an email input. For this I want to validate the email against certain domains i.e.

@gmail.com, @icloud.com, @me.com

I can see we have an email answer format in the form of this:

ORKEmailAnswerFormat()

However I can't see anywhere in this type that allows me to apply a validation regex. Looking into this I see we have the following

ORKAnswerFormat.textAnswerFormatWithValidationRegex(validationRegex, invalidMessage)

I suppose this is my best option? If so, would anyone know of a regex (my regex isn't the greatest!) in swift that would handle the 3 domains stated above?

I have something like this...(not the greatest i know!)

[A-Z0-9a-z._%+-]+@gmail.com

sukh
  • 328
  • 2
  • 16

1 Answers1

0
[A-Z0-9a-z._%+-]+@(?:icloud|me|gmail)\.com

(or, if you don't care about capturing:)

[A-Z0-9a-z._%+-]+@(icloud|me|gmail)\.com

Now I made two modifications. I escaped the . and I made it so that the other two domains are options.

I suggest that you convert the whole thing to lower case. I don't know Swift, but you may be able to use one of its functions or the i modifier:

(?i)[0-9a-z._%+-]+@(icloud|me|gmail)\.com
Laurel
  • 5,965
  • 14
  • 31
  • 57
  • Cheers buddy will leave it little longer to see if I can get a Research Kit answer - if not the ticks yours! – sukh May 12 '16 at 17:02