C # Determines if a string has an alternate instance of a letter and a character in a string

Source: Internet
Author: User

The example in this article describes how C # determines whether a string has a letter and the substitution of characters in a string. Share to everyone for your reference. The implementation method is as follows:

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

The following is an example of a string:

The code is as follows: string ss = "AaZ31 dd2f3";
String sss = ss. Replace ("", "");//Remove whitespace from string ss

String sss2 = Regex.Replace (ss, "[A-za-z]", "");//Remove the English letter from the string SS

MessageBox.Show (SSS);//dialog box popup value is AAZ31DD2F3
MessageBox.Show (SSS2);//dialog box popup value is 31 23

if (regex.matches (SS, "[A-za-z]"). COUNT>0)//If the number of captured letters is greater than 0

{

There is an English letter in the description string

}

Else

Instead

I hope this article is helpful to everyone's C # programming.

Url:http://www.jb51.net/article/56829.htm

C # Determines if a string has an alternate instance of a letter and a character in a string

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.