Hello,
I'm looking for a regex expression that would restrict a text entry to length x width x height style dimensions. Ideally, no limits to the number of digits available in the number part of the dimensions, x can be either lower or upper case.
Not super well versed in regex. I've managed to find good expressions from ESRI to get regex for email input to work , but I'm struggling with this one. I've used this stack overflow threat as reference but none have been successful:
https://stackoverflow.com/questions/39452200/match-product-dimensions-with-regular-expression
Solved! Go to Solution.
Hi @ZachBodenner ,
The basic pattern you're looking for has the following components in sequence:
Each of those parts has a corresponding part of the overall regex pattern. I'm going to assume a period (.) is the appropriate decimal separator in the example below:
Placing them together to get:
(\d+\.?\d*)(\s?x\s?)(\d+\.?\d*)(\s?x\s?)(\d+\.?\d*)
Hi @ZachBodenner ,
The basic pattern you're looking for has the following components in sequence:
Each of those parts has a corresponding part of the overall regex pattern. I'm going to assume a period (.) is the appropriate decimal separator in the example below:
Placing them together to get:
(\d+\.?\d*)(\s?x\s?)(\d+\.?\d*)(\s?x\s?)(\d+\.?\d*)
Hey, this is great, that explanation is so helpful! The only problem is that Survey123 Connect is giving me the below error:
Here's the xls form with the regex in the constraint column:
Update: it worked when I structured it this way:
regex(., '^(\d+\.?\d*)(\s?x\s?)(\d+\.?\d*)(\s?x\s?)(\d+\.?\d*)')
I used the email regex formatting as reference and added (.,'^ to the beggining.
Sidenote, what would my syntax be if I wanted the "x" to be either caps or lower case? The current format seems to mandate lower case.