Recent searches
No recent searches
Regex field for multiple 9 digit numbers
Posted Jun 15, 2021
Hi,
I have a requirement for a regex field that accepts a 9 digit number separated by a comma that can be used for more than 1 group of 9 digit numbers.
Example
111222333,444555666,777888999,
Behind the scenes one of our systems can pick this these numbers as long they are separated by a comma
Complications:
1. We don't know exactly how many groups of 9 digit numbers an end-user will put in it could once or it could be 10 times (the 9 digit numbers are product ID's)
2. If an end-user inputs only one ID e.g. 333444555 they may not use a comma can we force the comma? Or make the comma optional?
3. If they input more than one ID the last ID will need to end on a comma can we force this or again make the last I.D have an optional comma at the end?
The system we can set to pick up whatever is the best option for the rubular within the regex field.
After trying like a million times using rubular I have not been able to find the best method to fit my requirements.
Would anyone else have any idea how I could make this work?
Thank you very much!
0
3 comments
Dave Dyson
Hi Glen –
The following regex expression should match one or more of 9-digit numbers, separated by commas, with an optional comma at the end:
[0-9]{9}(,[0-9]{9})*,?
Hope that helps!
1
Auf Mir
Hi Dave,
Thank you that is great!
I was so close! Yet so far away...
Thank you for the support
0
Dave Dyson
Awesome, Glen - so glad I could help!
0