asp.net (C #) Code _ Regular expression using Rex regular to generate a string array

Source: Internet
Author: User
Look here. If you are familiar with regular expressions

, let's get to the point. The name of this tool is called regular Expression exploration. You can download it from here. The current version is 1.0 release. Rex is a command line tool,

Specific use can be executed under CMD can see the usage, this is. NET program. We can reference it and then use the code below to generate the string array we want.

Copy Code code 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[012789]|8[78]) \d{8}$";
Rexsettings settings = new Rexsettings (regex) {k = ten, 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 cell phone number. Set the number of builds is 10, encoding ASCII. There are many options. You can look at its members. These string data are used to do whatever you want.

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.