hope this fix your issue Taking into consideration locale-specific settings You certainly can do everything yourself, however you have an option to use VarI4FromStr or similar API which does dirty stuff for you. You put string in, you get LONG out. Locale aware.
Limit Text Field to one decimal point input, numbers only, and two characters after the decimal place - Swift 3
Hope that helps Normally, a special character would be anything other than alphanumeric characters. If your own definition is the same then you need a regex to capture decimal numbers to save them from being removed:
re = /(\d\.\d)|[^a-zA-Z\d]/
str = 'test1.3eb@j$2.xyz.'
subst = '\\1'
result = str.gsub(re, subst)