C determines whether a string has an alphabetic character and a replacement instance of the character in the string

  • 2020-12-05 17:20:15
  • OfStack

This article illustrates the C# method for determining the existence of letters in a string and the substitution of characters in a string. Share to everybody for everybody reference. Specific implementation methods are as follows:

First, add the namespace "using System.Text.RegularExpressions;" A reference to the

Here's an example of a string:

string ss = "aaZ31 dd2f3";
string sss = ss.Replace(" ", "");// The string ss Remove the space in string sss2 = Regex.Replace(ss, "[a-zA-Z]", "");// The string ss Remove the English letter from MessageBox.Show(sss);// The dialog box pops up with a value of aaZ31dd2f3
MessageBox.Show(sss2);// The dialog box pops up with a value of 31 23 if(Regex.Matches(ss,"[a-zA-Z]").Count>0)// If the number of captured letters is greater than zero {       // Indicates the existence of An English letter in a string } else        // And vice

Hopefully this article has helped you with your C# programming.


Related articles: