Regular Expression for text input validation

2
Hi Mendix Developers, I'm trying to create a regular expression to validate user input in a text box. The input should consist of a string representing a season (Winter, Spring, or Fall), followed by a space character, followed by a year between 2020 and 2099. Can anyone have an idea of a regular expression that matches this pattern and allows me to validate user input in Mendix? I tried some patterns, but they did not work. Just in case, I attach the screenshot of the example of what I tried below.  Thanks in advance for your help!
asked
3 answers
6

HI Takeyoshi,

 

This Regex may work for you,

 

(Winter|Spring|Fall) [2-9][0-9]{3}

Explanation:

  • (Winter|Spring|Fall) matches one of the three season names separated by the pipe symbol |.
  • [2-9] matches the first digit of the year between 2 and 9 (i.e., 2, 3, ..., 9).
  • [0-9]{3} matches any three digits (0-9), which correspond to the last three digits of the year. Together, [2-9][0-9]{3} matches any year between 2020 and 2099.

Therefore, this regular expression will match strings like Winter 2022, Spring 2034, Fall 2099, but will not match strings like Summer 2023 or Spring 1999.

 

Please try it and let me know,

 

Hope it helps!

answered
0

Hi All I have a Equivalent Question regarding this Actually  I  also need to validate some text  contains  Eg: starting with  PCO  in it  Follwed by Truck , van, Trailer etc in it   .we need some regular expression format for this text.

 

  1. PCO
  2. PCO  Truck
  3. PCO  VAN
answered
0

so  I tried like this  not working  in If else condition block in mendix 

isMatch($new/Location,'^PCO ')=  true   @Robert Price please help

 

answered