On 29-dec-2005, at 7:29, Christian Miller <realbasic at nc dot rr dot com>
wrote:
Hello. In an application I'm writing, I need to filter out non-
alphanumeric characters. Currently I loop through the text in the
editfield and manually filter A-Z, numbers, etc. This works great
for English. Can anyone share with me how I can accomplish the same
thing (automagically?) from within RB for non-English languages?
I recently wrote the following function to test whether a username is
valid. I accepts most common characters used in European languages.
You could modify it to strip anything that does not match the
criteria. I do hope that the extended characters are transferred
properly in this email.
Function IsValidUsername(IsValidUsername As String) As Boolean
Dim IsValid As Boolean = True
If IsValidUsername.Len < 2 Or IsValidUsername.Len > 20 Then
IsValid = False
End if
If IsValid Then
' Make sure that both value and pattern are in the same 8-bit
encoding
Dim Value, Pattern As String
Value = ConvertEncoding( IsValidUsername, Encodings.WindowsANSI )
Pattern = ConvertEncoding( "([a-zA-Z0-9À-ÖØ-öø-ÿ_\-\.]+)",
Encodings.WindowsANSI )
IsValid = Value.MatchRegEx( Pattern )
End if
Return IsValid
End Function
HTH,
- Rob Laveaux
--------------------------------------------------------
Pluggers Software
Thijssestraat 203
2521 ZG Den Haag
The Netherlands
Email: rob dot laveaux at pluggers dot nl
Website: http://www.pluggers.nl
--------------------------------------------------------
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
|