Replacing regular expression with keycode data
-
22-09-2019 - |
Question
Public ReadOnly Property IsAlphaNumeric(ByVal entry As String) As Boolean
Get
Return New Regex("(?!^[0-9]*$)(?!^[a-zα-ωA-ZΑ-Ω]*$)^([a-zα-ωA-ZΑ-Ω0-9]{6,15})$", RegexOptions.IgnoreCase).IsMatch(entry)
End Get
End Property
This one is pretty good for Greek and English language.
What about all the other languages in the universe?
Should i replace the above code with another function, validating keycode data and text length or what?
Solution
I would recommend to use unicode character definitions instead, such as \p{L}
for letters and \p{N}
for numbers.
You can find documentation on which categories that are recognized at MSDN.
However, I am not sure whether it supports the Klingon alphabet.
OTHER TIPS
This one is brilliant also! Found at a1vbcode.com
Public Function IntlIsAlphaCharacter(sChar As String) As Boolean
IntlIsAlphaCharacter = (Not (UCase(sChar) = LCase(sChar))) Or (sChar = " ")
End Function
The native language of klingons is regex's?
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow