Mode |
Description |
^d{5}$ |
5 numeric numbers, such as U.S. ZIP codes. |
^ (d{5}) | (d{5}-d{4}$ |
5 numeric digits or 5 digits-dashes-4 digits. United States ZIP code that matches 5-digit number format, or 5-digit + 4-digit number format. |
^ (D{5} (-d{4})? $ |
Same as the previous one, but more effective. Use? You can make the 4-digit number in the pattern optional, rather than requiring a different two pattern (in another way). |
^[+-]?d+ (. d+)? $ |
Matches any real number with an optional symbol. |
^[+-]?d*.? d*$ |
Same as previous, but also matches an empty string. |
^ (20|21|22|23| [01]d) [0-5]d$ |
Matches a 24-hour time value. |
/*.**/ |
Match C-language-style annotation/* ... * |
Get the number method in a string
String S= "";
foreach (Match m in Regex.Matches (s,@ "d+"))
{
Console.WriteLine (M.value);
}
Go to the end of the string numeric method
String str = "007";
String pattern = @ "(. +?) (d+) $ ";
string result = System.text.regularexpressions.regex.replace (str, pattern, "$");
-
<summary>
Get a number in a string
</summary>
<param name= "par" ></param>
<returns></returns>
private int GetNumber (string par)
{
String Strtempcontent =par;
Strtempcontent = System.text.regularexpressions.regex.replace (strtempcontent, @ "[^d]*", "");
Return Convert.ToInt32 (strtempcontent);