I have a single line input field requiring the regular expression, "/.+@domian\.edu/i," and it does not recognize my email "tjknight@domain.edu" as a match, even though I've confirmed from multiple sources that they should match. Is there something I'm missing when setting up a regular expression?
Question
Question
Has any one run into an issue with regular expressions not working in Forms?
Answer
Following Jason Smith's example from Forms email question - Laserfiche Answers, I found that
^.*[@okwu\.edu]$
works where
/.+@okwu\.edu/i/
doesn't. I'm still not sure why. I also found that regex101.com is a good resource for checking these expressions.
^.*[@okwu\.edu]$
I don't think this is doing what you want. The pieces are:
- Beginning of string
- Any number of any character
- A single character from the set "@okwu.edu"
- The end of the string.
When you tested your email, most of it would have been matched by the ".*" part, and the final "u" would match from the "@okwu.edu". I think you want to remove the [].
That's very helpful! Thank you!
And as for the slashes, that is a common bit of syntax to indicate that the characters in between should be interpreted as a regular expression. It's similar to how quote characters are used to delimit strings. In Javascript, `/somepattern/` is essentially the same as `new RegExp("somepattern")`, and the slash syntax is supported by some other languages as well. The terminology around this gets confusing - does "regular expression" refer to the pattern itself or the programming language object that you actually use? Anywhere one of our products has you enter a regular expression, it wants just the pattern so you'll want to exclude any slashes. Also, the trailing "i" is for "case insensitive"; there are other flags that could be there, but "i" is most common.