Best practice for testing only numbers in alphanumeric field
Hi. I am looking for the communities thoughts on best practice for testing only numbers exist in alphanumeric fields (useful for number only fields where we want to include leading 0s).
We are currently deciding on our standard approach. We currently use Regex as it's efficient and precise. The 'To Number' option is too dangerous as modifies the data (see pic for examples).
I have also seen this post with some other good ideas but wanted specific thoughts on best practice:
Thanks all
Best Answer
-
Hi Jasper, I think your current approach of using regex would be best practice here as you can specifically check for a numeric value, regardless of datatype.
Probably worth creating a couple of re-usable functions for the benefit of other Aperture users.
There's a couple that I would suggest:
- Is Numeric Value - a simple regular expression which checks for numbers only within a string
2. Is Numeric Value (including decimals and negative numbers)
Hope this helps,
Dan
3
Answers
-
Seems like we were on our way to best practice with Regex but can enhance it with more specificity (e.g. negative, decimal) and make them reusable functions. This was exactly the sort of guidance I was after. Thank you Dan
1