Dim input As String = "Hi! Hello, How are you?" Dim pattern As String = "[!""#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~\s]" Dim matches As MatchCollection = Regex.Matches(input, pattern) MessageBox.Show(String.Format("There are {0} special characters in the input '{1}'", matches.Count, input))
[!""#$%&'()*+,\-.\/:;<=>?@[\\\]^_`{|}~\s]
For Each m As Match In matches MessageBox.Show(String.Concat("Found: '", m.Value, "'")) Next m
Quote:How to get special characters from a string in VB.NET
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)