cancel
Showing results for 
Search instead for 
Did you mean: 
lmaggiulli
Occasional Member - Level 2

Regular Expression

Dear all, 

 

is there a regular expression that allow me to force the user to fill in at least one fixed words? Example: Comment field, the employee has to insert at leat the value "AAAAAA" or "BBBBB" but also could add other free text.

 

Thanks.

 

Lorenzo

1 REPLY 1
PoojaKumatkar
Frequent Member - Level 1

Hi @lmaggiulli ,

 

1. What are those fixed words that are allowed to use?

2. Also, just wondering, if you want to allow them to enter anything then what is the purpose of adding field validation? 

 

 

Try below:

 

Regular Expression - ^(AAAAAA|BBBBBB) - .*$

Note - 

 

  • (AAAAAA|BBBBBB) - Matches either "AAAAAA" or "BBBBBB". Replace this with your fixed words.
  • | is the OR operator, so it matches either of the two values.
  • - - Ensures that there is a hyphen after "AAAAAA" or "BBBBBB".
  • .* - Matches any characters (zero or more) after the hyphen (i.e., free text).

PoojaKumatkar_0-1740401322756.png

 

 

 

Testing Result: 

PoojaKumatkar_1-1740401370862.pngPoojaKumatkar_2-1740401392772.png

PoojaKumatkar_3-1740401415137.png

PoojaKumatkar_4-1740401436048.pngPoojaKumatkar_5-1740401461778.pngPoojaKumatkar_6-1740401478394.png

 

If this answers your query, then please mark solution as accepted.

 

 

 

Thanks!
Regards,
Pooja