Regular expression failing in exclusive split but functional in Validator widget.

0
Hi there, I am using the following reg-ex to validate a address in English format. This expression fails when i use it in the modeler as follows: isMatch($ResidentialAddress/Address1,'^([0-9]\+) ([A-Za-z]\+)$') or isMatch($ResidentialAddress/Address1,'([0-9]+) ([A-Za-z]+)) I have tried both in an exclusive split and both seem to fail, however this ([0-9]+) ([A-Za-z]+) expression works when using the Validator widget. Any advice on what could be the difference issue between the widget and an exclusive split? Thank you
asked
2 answers
0

According to your regular expression you cannot have white spaces in the text.

You gave the address: 24 Tamboti Road as an example, which isn't valid. My guess is that: " 24TambotiRoad" will pass your validation. Apparently the validator widget ignores whitespaces.

It really depends on how strict you want to validate, I would recommend taking a look at the site https://regex101.com/ this allows you to test some regular expressions and you'll see that your expression only matches the first part of the address. Due to the whitespace the word "Road" doesn't match the expression.

You could for example use: (\d+)(\s)(\D+) which says: Multiple digits followed by 1 whitespace character, followed by multiple non-Digits. However this wouldn't allow you to use numbers but does allow for special characters.

answered
0

See my post https://forum.mendix.com/questions/7871/How-to-check-if-the-first-character-of-a-string-is-a-number

I still think there is a bug in Mendix. When the string is 12 the regex '^[0-0]' will fail. To my opinion Mendix falsly rejects it because the string is more then one character. Any regex tester I tried gives a match, but only Mendix will reject it....

Regards,

Ronald

[EDIT]

There was a typo in the regex should have been^ [0-9]. But when I enter this and enter the string 12 it will give a match. Regex matches

answered