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

Question

Question

Regular Express to Eliminate a Word

asked on August 17, 2018

Hello all,

I seem to be struggling with the appropriate regular expression that I need to put on a form field.  It is a single line text field.  I want to allow them to type any words they want EXCEPT 'Other' or 'other'.

 

I have ^((?!Other).)*$ which works to flag it as invalid if they type Other.  But I am struggles to get the case sensitivity issue resolved because they can still type other.

 

Much thanks for any help I can get.

 

0 0

Answer

SELECTED ANSWER
replied on August 17, 2018

Theoretically you should be able to do something like this:

^((?!(?i)other).)*$

The (?i) tells the regex engine to ignore case, which would allow you to look out for all the combinations such as "Other", "other", or "oTHEr". However when I tested it in Forms, it won't accept that regex.

Failing that, you can use the pipe character to define an OR:

^((?!Other|other).)*$

 

0 0
replied on August 18, 2018 Show version history

Thanks.  I was trying to place my pipe in the wrong place.  I tried the first option to ignore case but the Regular expression for validation flags it as invalid input.

RegExInvalid.png
0 0
replied on August 20, 2018

An invaluable good resource and testing tool..... www.regex101.com

2 0
replied on August 20, 2018

Indeed. Although, sometimes the specific flavor that Laserfiche is using is slightly different than others.

0 0
replied on March 12, 2019

I'll second both the regex101.com tool and the warning that Laserfiche can be a tad different from what regex101.com thinks will work. Laserfiche does things differently with line breaks in some of the regex I've tested as good on regex101.

0 0

Replies

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

Sign in to reply to this post.