{"id":55,"date":"2008-02-23T16:09:07","date_gmt":"2008-02-23T20:09:07","guid":{"rendered":"http:\/\/jianmingli.com\/wp\/?p=55"},"modified":"2013-02-05T10:14:18","modified_gmt":"2013-02-05T15:14:18","slug":"c-regex","status":"publish","type":"post","link":"https:\/\/jianmingli.com\/wp\/?p=55","title":{"rendered":"C# RegEx"},"content":{"rendered":"<p><strong>Overview<\/strong><\/p>\n<ul>\n<li>Namespace: System.Text.RegularExpressions<\/li>\n<li>Classes<\/li>\n<ul>\n<li>Capture: Results of a single match<\/li>\n<li>CaptureCollection<\/li>\n<li>Group: Result of a single group capture<\/li>\n<li>Match: Result of a single expression match<\/li>\n<li>MatchCollection<\/li>\n<li>MatchEvaluator: A delegate for use during replacement operations<\/li>\n<li>Regex: An instance of compiled regular expression<\/li>\n<ul>\n<li>Escape()<\/li>\n<li>IsMatch()<\/li>\n<li>Match()<\/li>\n<li>Matches()<\/li>\n<li>Replace()<\/li>\n<li>Split()<\/li>\n<li>Unescape()<\/li>\n<\/ul>\n<\/ul>\n<p><strong>Examples<\/strong><\/p>\n<ul>\n<li>Simple matches\n<pre lang=\"csharp\">\r\nMatch m = Regex.Match(\r\n  \"abracadabra\", \"(a|b|r)+\");\r\nif (m.Success)\r\n{\r\n  log.Debug(\"Match string: \" \r\n    + m.Value); \r\n  \/\/ Match string: abra\r\n}\r\n<\/pre>\n<\/li>\n<li>String replacement\n<pre lang=\"csharp\">\r\nRegex.Replace(\r\n\"abracadabra\", \"abra\", \"zzzz\")\r\n\/\/ zzzzcadzzzz\r\n<\/pre>\n<\/li>\n<li>Not alphanumeric: [^a-zA-Z0-9]<\/li>\n<li>US zipcode: @&#8221;\\d{5}([\\-]\\d{4})?&#8221;<\/li>\n<\/ul>\n<\/ul>\n<p><strong>References<\/strong><\/p>\n<ul>\n<li><a href=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/1400241x.aspx\">Regular Expression Syntax (Scripting)<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Overview Namespace: System.Text.RegularExpressions Classes Capture: Results of a single match CaptureCollection Group: Result of a single group capture Match: Result of a single expression match MatchCollection MatchEvaluator: A delegate for use during replacement operations Regex: An instance of compiled regular &hellip; <a href=\"https:\/\/jianmingli.com\/wp\/?p=55\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[5],"tags":[556,607],"class_list":["post-55","post","type-post","status-publish","format-standard","hentry","category-c","tag-c","tag-regex"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8cRUO-T","_links":{"self":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/55","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=55"}],"version-history":[{"count":1,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/55\/revisions"}],"predecessor-version":[{"id":7183,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/55\/revisions\/7183"}],"wp:attachment":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=55"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=55"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=55"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}