I am trying to restrict a user from inputting a wrong string in a form field in Access
.
I am trying to determine whether a string
is of the form "1, 2, 54, 765, 43222".
The sequence is
- a strictly positive integer
- a comma
- a space (␣)
and this sequence can be repeated an unknown number of times.
I have tried using the String Like
function with "#, #"
but have hit my head against the wall on how to allow this pattern to possibly repeat.
I am also open to Regex
patterns, even though, I have a very limited amount of knowledge and understanding of this. I have tried with a pattern "\d+, +"
and "(\d+, )+"
, but I am not convinced this is correct.
Another solution could be using substring
and searching for single occurrences of the pattern in the first three characters of the supplied string, trimming the string removing the first three characters and repeating this action.
To give you some examples:
- "1, 2, 3, 4" should return true
- "1,2, 3, 4" should return false
- "a, 3, 65!, 34" should return false
- "1, 3, 2, 4, 5442" should return true
I hope my description is sufficient.
Thanks in advance.