Advertisement.

TransHimalaya.in

Everest Helicopter Tour for a day

Book exciting packages at www.transhimalaya.in

Remove special character/Nonnatural character from string/filename

Remove special character/Nonnatural character from string/filename

it's useful to have filename without special characters...


Public Shared Function strip(ByVal str As String) As String
               Return Regex.Replace(str, "[\[\]\\\^\$\|\?\*\+\(\)\{\}%,;>
    End Function
' Put \ with your character. to include dot use \.


another old method



Public Shared Function strip(ByVal str As String) As String
         remove nonnatural characters
        Dim intCounter As Integer
        Dim arrSpecialChar() As String = {",", "<", ">", ":", "?", """", "/", "{", "[", "}", "]", "`", "~", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "-", "+", "=", "|", " ", "\"}


       intCounter = 0
        Dim i As Integer
        For i = 0 To arrSpecialChar.Length - 1


           Do Until intCounter = 28
               str = Replace(str, arrSpecialChar(i), "")
                intCounter = intCounter + 1


            Loop
           intCounter = 0
        Next
        Return str


     
    End Function

Comments

Most Viewed Post

solution for facebook static.ak.fbcdn.net waiting

Connect Sony XPLOD MEX-BT2500 Bluetooth CD Receiver with ur mobile

Crystal Report : Show data horizontally (Left to right) i.e. columns as rows

Google+ Followers