Asp.net (C #) uses Rex regular to generate the code of the string array

Source: Internet
Author: User

Here, if you are familiar with regular expressions

Let's go to the topic. The tool name is regular expression configuration. You can download it from here. The current version is 1.0 Release. Rex, which is a command line tool,

You can run the command in cmd to see the usage. This is. netProgram. We can reference it and use the following code to generate the string array we want.

CopyCode The Code is as follows: // <summary>
/// Generates the test.
/// </Summary>
/// <Remarks> author Petter Liu http://wintersun.cnblogs.com </remarks>
[Test]
Public void generatetest ()
{
String RegEx = @ "^ 1 (3 [4-9] | 5 [1, 012789] | 8 [78]) \ D {8} $ ";
Rexsettings settings = new rexsettings (RegEx) {k = 10, encoding = characterencoding. ASCII };
VaR Results = rexengine. generatemembers (settings );
Foreach (VAR result in results)
{
Console. writeline (result );
}
}

Output:

18897190518
18889349691
18792280668
18831202949
15789824598
15998890392
13709912389
18779992048
13967892889
15928882992

Here we use the regular expression of the mobile phone number. set the number of generations to 10, encoded in ASCII format. there are many options. you can view its members. you can use the string data for your purposes.

Author: Petter Liu

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.