Strip Chars from a string

  • Thread starter Thread starter Nikolay Petrov
  • Start date Start date
N

Nikolay Petrov

I need a way to strip chars from a string. The chars are all chars that are
not allowed in file path.

TIA
 
Nikolay,

The answer can be
dim mypath = mypath.replace("char"c,""c)

or even better in this case
use regex.

However this is probably not what you mean

Cor
 
Long way to do it is. First identify the characters that you don't want. Use
Instr, Left and Right to strip them of.

chanmm
 
Nikolay Petrov said:
I need a way to strip chars from a string. The chars are all chars that are
not allowed in file path.

\\\
Imports System.Text.RegularExpressions
..
..
..

' Put not allowed characters between square brackets. Notice that
' some characters have a special meaning in regular expressions and
' thus you must escape them by preceeding them with a backslash.
Dim s As String = "[?:/]"
Dim t As String = "C::\/bla??"
MsgBox(Regex.Replace(t, s, ""))
///
 
Back
Top