vbnet Clean Class

Public Class Clean
    Public Property Data As String
    Private objRegEx As Regex

    Public Sub AlphaNumeric()
        'AlphaNumeric whitelist
        objRegEx = New Regex("[^-a-zA-Z0-9-_ ]")
        Data = objRegEx.Replace(Data, "")
    End Sub

    Public Sub MaxLength(ByVal Length As Int32)
        'trims a string to a specified length
        If Data.Length > Length Then
            Data = Left(Data, Length)
        End If
    End Sub
End Class
Basic implementation of a Clean Class, for expanding with methods for various Regular Expressions.

Updated: Saturday 9th October 2010, 09:18pm

There are 0 comments

Leave a comment of your own

Comments are currently closed.