In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article is about what regular expressions are commonly used in C#. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Summary description of using System; using System.Text.RegularExpressions; namespace CommonTools {/ * * / RegexLib. / public class RegexLib {/ / verify the Email address public static bool IsValidEmail (string strIn) {/ / Return true if strIn is in valid e-mail format. Return Regex.IsMatch (strIn, @ "^ ([\ w -\] +) @ (\ [[0-9] {1pr 3}\. [0-9] {1pr 3}\.) | (([\ w -] +\.) +)) ([a-zA-Z] {2} 4} | [0-9] {1pr 3}) (\]) $");} / / the date form of dd-mm-yy instead of mm/dd/yy. Public static string MDYToDMY (String input) {return Regex.Replace (input, "\\ b (?\ d {1Magne2}) / (?\ d {1Power2}) / (?\ d {2year 4})\ b", "${day}-${month}-${year}");} / / verify whether it is a decimal public static bool IsValidDecimal (string strIn) {return Regex.IsMatch (strIn,@ "[0].\ d {1pm 2} | [1]"). } / / verify whether it is the phone number public static bool IsValidTel (string strIn) {return Regex.IsMatch (strIn,@ "(\ dwatch -)? (\ d {4} -?\ d {7} |\ d {3} -?\ d {8} | ^\ d {7pr 8}) (-\ d +)?) } / / verify public static bool IsValidDate (string strIn) {return Regex.IsMatch (strIn) @ "^ 2\ d {3}-(?: 0? [1-9] | 1 [0-2])-(?: 0? [1-9] | [1-2]\ d | 3 [0-1]) (?: 0? [1-9] | 1\ d | 2 [0-3]): (?: 0? [1-9] | [1-5]\ d): (?: 0? [1-9] | [1-5]\ d)") } / / verify that the suffix name public static bool IsValidPostfix (string strIn) {return Regex.IsMatch (strIn,@ "\. (? i:gif | jpg) $");} / / verify that the character is between 4 and 12 public static bool IsValidByte (string strIn) {return Regex.IsMatch (strIn,@ "^ [a Mizz] {4jue 12} $") } / / verify IP public static bool IsValidIp (string strIn) {return Regex.IsMatch (strIn) @ "^ (\ d {1Magne2} | 1\ d\ d | 2 [0-4]\ d | 25 [0-5])\. (\ d {1-4]\ d | 2 [0-4]\ d | 25 [0-5])\. (\ d {1-4]\ d | 2 [0-4])\ d | 25 [0-5])\. (\ d {1} 2} | 1\ d\ d | 2 [0-4]\ d | 25 [0-5] $") } Thank you for reading! This is the end of this article on "what regular expressions are commonly used in C#". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.