You are viewing limited content. For full access, please sign in.

Question

Question

Has any one run into an issue with regular expressions not working in Forms?

asked on April 23

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? 

0 0

Answer

SELECTED ANSWER
replied on April 23

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. 

1 0
replied on April 23
^.*[@okwu\.edu]$

I don't think this is doing what you want. The pieces are:

  1. Beginning of string
  2. Any number of any character
  3. A single character from the set "@okwu.edu"
  4. 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 [].

2 0
replied on April 25

That's very helpful! Thank you!

0 0
replied on April 26

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.

0 0

Replies

replied on April 23

Creating your regex using the token editor answers this for you. As Travis showed, you should be using "^" to signify the beginning of the input instead of "/", and using "$" to signify the end of the input instead of "/i".

1 0
replied on April 25

Was that changed at some point? Because this is a legacy form and I'm trying to work through our catalog of processes. 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.