Regex validation error: Your regular expression can take too much time to complete, please use another one

(Imad Jundi) #1

Hi Flowxo ,
I am trying to validate a text input to accept at least 3 words
user can enter 3,45, or more word but not less
i tried
^\s*([a-zA-Z]+\s*){1,3}$

but it’s saying
Your regular expression can take too much time to complete, please use another one.

(Daniel Beckett) #2

@Jundi

Where are you using the Regex? Are you using the Text service?

(Imad Jundi) #3

Ask Question
type: Text
Validation: Regex

(Daniel Beckett) #4

@Jundi

It looks like the question service doesn’t like that particular expression. Most likely due to a quantifier being used, e.g.

* (0 or more)
+ (1 or more)
? (0 or 1)

These can be dangerous in some expressions (search for an infinite value for example) so we need to use caution when handling them unfortunately. I’ve raised this with our development team to look into the Regex validation to see if there’s any changes we can make for handling expressions which use the quantifiers.

Since you’re trying to validate based off of number of words rather than characters I think the only solution at the moment would be to use the Code service.