{"id":5029,"date":"2021-04-30T13:28:25","date_gmt":"2021-04-30T12:28:25","guid":{"rendered":"https:\/\/solidt.eu\/site\/?p=5029"},"modified":"2022-07-25T08:31:28","modified_gmt":"2022-07-25T07:31:28","slug":"c-regex-duplicate-words","status":"publish","type":"post","link":"https:\/\/solidt.eu\/site\/c-regex-duplicate-words\/","title":{"rendered":"C# Regex Duplicate Words"},"content":{"rendered":"\n<p>Source: <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/standard\/base-types\/regular-expressions\">https:\/\/docs.microsoft.com\/en-us\/dotnet\/standard\/base-types\/regular-expressions<\/a><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">using System;\nusing System.Text.RegularExpressions;\n\npublic class Class1\n{\n   public static void Main()\n   {\n      string pattern = @\"\\b(\\w+?)\\s\\1\\b\";\n      string input = \"This this is a nice day. What about this? This tastes good. I saw a a dog.\";\n      foreach (Match match in Regex.Matches(input, pattern, RegexOptions.IgnoreCase))\n         Console.WriteLine(\"{0} (duplicates '{1}') at position {2}\",\n                           match.Value, match.Groups[1].Value, match.Index);\n   }\n}\n\/\/ The example displays the following output:\n\/\/       This this (duplicates 'This') at position 0\n\/\/       a a (duplicates 'a') at position 66<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Source: https:\/\/docs.microsoft.com\/en-us\/dotnet\/standard\/base-types\/regular-expressions<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[6,4,1],"tags":[],"class_list":["post-5029","post","type-post","status-publish","format-standard","hentry","category-dotnet","category-programming","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/5029","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/comments?post=5029"}],"version-history":[{"count":2,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/5029\/revisions"}],"predecessor-version":[{"id":5032,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/5029\/revisions\/5032"}],"wp:attachment":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/media?parent=5029"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/categories?post=5029"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/tags?post=5029"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}