Regular Expression

0
Hello, For my application I need to make an regular expression. Is there someone who can help me out? I tried something but i won't succeed. The regular expressions needs to meet the following requirement. abbrivation of 2 letters "." 1 letter + 1 number "." 3 numbers between each section there must be an "." without any spaces. Hope someone can help me out! :)
asked
3 answers
1

The most simple solution: [A-Za-z][A-Za-z]\.[A-Za-z][0-9]\.[0-9][0-9][0-9]

Slightly improved: [A-Za-z]{2}\.[A-Za-z][0-9]\.[0-9]{3}

My tool of choice is regex101.com. See this example: https://regex101.com/r/GZnxce/3

 

answered
0

On this site you can test your regular expressions more easily: https://regex101.com/
Within Mendix you can use the regex java action which can be found in the community commons module.

 

An other solution is that if the structure is always the same, you could use the substring function to check more easily.

substring('aa.a1.111', 0,2) -> use a regex for only letters
substring('aa.a1.111', 2,1) -> compare with '.' because it needs to be a point.
substring('aa.a1.111', 3,1) -> use a regex for only letters
substring('aa.a1.111', 4,1) -> use a regex for only numbers
substring('aa.a1.111', 5,1) -> compare with '.' because it needs to be a point.
substring('aa.a1.111', 6,3) -> use a regex for only numbers
answered
0

Hi Dwayne,

You can use this easy tool to construct regexes: http://buildregex.com/

answered