3
Views
2
Comments
Check whether a string contains no letters
Question
I have a field whose values has to be like "1,2,3,4". I want to make sure that no letters or other characters besides numbers (0-9) and comma (,) are entered.

I have used Regex_search with "(\d+)(,\s*\d+)*" regular expression, but since Regex_search doesn't do a complete match, entries like "1,2,a,4;7" are accepted and saved into the database. 

Any suggestions?

Regards,

 
UserImage.jpg
Nuno Palhinhas
Staff
Hi,

Did you included the beginning and end of string chars (^ ... $)?
Like this: ^(\d+)(,\s*\d+)*$
It should work with these.

Nuno
2020-03-05 15-52-45
André Vieira
Staff
If you get this from the user's input you might want to consider having an input mask on your input. There's a forge component for this.
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.