asp.net (C #) code to generate string arrays using Rex regularization

Time:2021-4-13

Look here. If you’re familiar with regular expressions

This tool is called regular expression exploration. You can download it from here. The current version is 1.0 release,

The specific usage can be seen by executing in CMD. This is a. Net program. We can refer to it, and then use the following code to generate the string array we want

Copy codeThe 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[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 mobile phone number. Set the generated number to 10 and encode ASCII. There are many options. You can see its members. What these string data are used for depends on you

Author: Petter Liu