{"id":14926,"date":"2022-10-09T16:37:12","date_gmt":"2022-10-09T11:07:12","guid":{"rendered":"https:\/\/jassweb.com\/solved\/solved-how-can-i-extract-the-info-between-c\/"},"modified":"2022-10-09T16:37:12","modified_gmt":"2022-10-09T11:07:12","slug":"solved-how-can-i-extract-the-info-between-c","status":"publish","type":"post","link":"https:\/\/jassweb.com\/solved\/solved-how-can-i-extract-the-info-between-c\/","title":{"rendered":"[Solved] How can i extract the info between &#8221; &#8221; ? C#"},"content":{"rendered":"<p> [ad_1]<br \/>\n<\/p>\n<div id=\"answer-11260616\" class=\"answer js-answer accepted-answer js-accepted-answer\" data-answerid=\"11260616\" data-parentid=\"11260038\" data-score=\"0\" data-position-on-page=\"2\" data-highest-scored=\"0\" data-question-has-accepted-highest-score=\"0\" itemprop=\"suggestedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n<div class=\"post-layout\">\n<div class=\"votecell post-layout--left\"><\/div>\n<div class=\"answercell post-layout--right\">\n<div class=\"s-prose js-post-body\" itemprop=\"text\">\n<p>Try this demo, put it in a Main method of a console application (it uses Regex so you have to add line &#8220;using System.Text.RegularExpressions;&#8221;):<\/p>\n<pre><code>        string input = \"AT+CMGL=\\\"ALL\\\"\\n+CMGL: 0,\\\"REC READ\\\",\\\"+40728072005\\\",,\\\"12\/06\/29,13:04:26+12\\\"\\npassword,1,ON\";\n        var matches = Regex.Matches(\n            input,\n            @\"\\\"\"(?&lt;msisdn&gt;\\+\\d*)\\\"\",.*,\\\"\"(?&lt;date&gt;\\d{2}\\\/\\d{2}\/\\d{2},\\d{2}:\\d{2}:\\d{2}\\+\\d{2})\\\"\".*\\n+(?&lt;passwd&gt;[^,]*),(?&lt;itemno&gt;\\d*),(?&lt;command&gt;\\w*)\"\n            , RegexOptions.Multiline);\n\n        foreach (Match m in matches)\n        {\n            Console.WriteLine(m.Groups[\"msisdn\"].Value);\n            Console.WriteLine(m.Groups[\"date\"].Value);\n            Console.WriteLine(m.Groups[\"passwd\"].Value);\n            Console.WriteLine(m.Groups[\"itemno\"].Value);\n            Console.WriteLine(m.Groups[\"command\"].Value);\n        }\n        Console.ReadKey();\n<\/code><\/pre>\n<p>Basically, regular expression searches for a defined pattern inside text.<br \/>\nMeaning of the expression:<\/p>\n<p>\\&#8221;&#8221; &#8211; that&#8217;s how a quote sign is defined, it is escaped with backslash and written twice so it doesn&#8217;t cause compiler error.<\/p>\n<p>(?+\\d*) &#8211; generally, bracketed expression means that you are capturing a group, this here is a named group and it&#8217;s name is specified by ?, this group is going to capture string that begins with + sign (it is escaped by backslash) followed by numbers which are represented by backslash and letter &#8220;d&#8221; (&#8220;d&#8221; comes from &#8220;digit&#8221;). Backslash is used as an escape character for characters with special meaning. Asterisk * means that character that comes before it can occur 0 or more times.<\/p>\n<p>\\&#8221;&#8221; &#8211; quote, this is closing quote for &#8220;msisdn&#8221; number.<\/p>\n<p>, &#8211; means comma.<\/p>\n<p>.* &#8211; dot means any character, and asterisk that follows it means that any character can occur 0 or more times.<\/p>\n<p>(?\\d{2}\/\\d{2}\/\\d{2},\\d{2}:\\d{2}:\\d{2}+\\d{2}) &#8211; named group that captures date, expression \\d{2} has \\d which means digit and {2} which tells regex engine that digit shoud occur two times, then comes \/ &#8211; it means forwardslash (it is escaped by a backslash). Afterwards come digits separated by colons and in the end plus sign and two digits after it, that&#8217;s how the date is extracted.<\/p>\n<p>\\n+ &#8211; \\n means newline, + is a quantifier which means that newline appears one or more times.<\/p>\n<p>(?[^,]*) &#8211; is a named group that captures password part, [^,] means that any character except comma should be captured, square brackets mean range of characters, ^ means negation, asterisk means that character can occur 0 or more times.<\/p>\n<p>(?\\d*) &#8211; is a named group that captures numbers as defined by \\d*<\/p>\n<p>(?\\w*) &#8211; is a named group that captures word characters (letters, digits, and underscores)<\/p>\n<\/p><\/div>\n<div class=\"mt24\"><\/div>\n<\/div>\n<p>            <span class=\"d-none\" itemprop=\"commentCount\">8<\/span> <\/p><\/div>\n<\/div>\n<p>[ad_2]<\/p>\n<p>solved How can i extract the info between &#8221; &#8221; ? C# <\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad_1] Try this demo, put it in a Main method of a console application (it uses Regex so you have to add line &#8220;using System.Text.RegularExpressions;&#8221;): string input = &#8220;AT+CMGL=\\&#8221;ALL\\&#8221;\\n+CMGL: 0,\\&#8221;REC READ\\&#8221;,\\&#8221;+40728072005\\&#8221;,,\\&#8221;12\/06\/29,13:04:26+12\\&#8221;\\npassword,1,ON&#8221;; var matches = Regex.Matches( input, @&#8221;\\&#8221;&#8221;(?&lt;msisdn&gt;\\+\\d*)\\&#8221;&#8221;,.*,\\&#8221;&#8221;(?&lt;date&gt;\\d{2}\\\/\\d{2}\/\\d{2},\\d{2}:\\d{2}:\\d{2}\\+\\d{2})\\&#8221;&#8221;.*\\n+(?&lt;passwd&gt;[^,]*),(?&lt;itemno&gt;\\d*),(?&lt;command&gt;\\w*)&#8221; , RegexOptions.Multiline); foreach (Match m in matches) { Console.WriteLine(m.Groups[&#8220;msisdn&#8221;].Value); Console.WriteLine(m.Groups[&#8220;date&#8221;].Value); Console.WriteLine(m.Groups[&#8220;passwd&#8221;].Value); Console.WriteLine(m.Groups[&#8220;itemno&#8221;].Value); Console.WriteLine(m.Groups[&#8220;command&#8221;].Value); } Console.ReadKey(); Basically, regular expression &#8230; <a title=\"[Solved] How can i extract the info between &#8221; &#8221; ? C#\" class=\"read-more\" href=\"https:\/\/jassweb.com\/solved\/solved-how-can-i-extract-the-info-between-c\/\" aria-label=\"More on [Solved] How can i extract the info between &#8221; &#8221; ? C#\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[320],"tags":[684,324,555],"class_list":["post-14926","post","type-post","status-publish","format-standard","hentry","category-solved","tag-buffer","tag-c","tag-serial-port"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>[Solved] How can i extract the info between &quot; &quot; ? C# - JassWeb<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jassweb.com\/solved\/solved-how-can-i-extract-the-info-between-c\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Solved] How can i extract the info between &quot; &quot; ? C# - JassWeb\" \/>\n<meta property=\"og:description\" content=\"[ad_1] Try this demo, put it in a Main method of a console application (it uses Regex so you have to add line &#8220;using System.Text.RegularExpressions;&#8221;): string input = &quot;AT+CMGL=&quot;ALL&quot;n+CMGL: 0,&quot;REC READ&quot;,&quot;+40728072005&quot;,,&quot;12\/06\/29,13:04:26+12&quot;npassword,1,ON&quot;; var matches = Regex.Matches( input, @&quot;&quot;&quot;(?&lt;msisdn&gt;+d*)&quot;&quot;,.*,&quot;&quot;(?&lt;date&gt;d{2}\/d{2}\/d{2},d{2}:d{2}:d{2}+d{2})&quot;&quot;.*n+(?&lt;passwd&gt;[^,]*),(?&lt;itemno&gt;d*),(?&lt;command&gt;w*)&quot; , RegexOptions.Multiline); foreach (Match m in matches) { Console.WriteLine(m.Groups[&quot;msisdn&quot;].Value); Console.WriteLine(m.Groups[&quot;date&quot;].Value); Console.WriteLine(m.Groups[&quot;passwd&quot;].Value); Console.WriteLine(m.Groups[&quot;itemno&quot;].Value); Console.WriteLine(m.Groups[&quot;command&quot;].Value); } Console.ReadKey(); Basically, regular expression ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jassweb.com\/solved\/solved-how-can-i-extract-the-info-between-c\/\" \/>\n<meta property=\"og:site_name\" content=\"JassWeb\" \/>\n<meta property=\"article:published_time\" content=\"2022-10-09T11:07:12+00:00\" \/>\n<meta name=\"author\" content=\"Kirat\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kirat\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-can-i-extract-the-info-between-c\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-can-i-extract-the-info-between-c\/\"},\"author\":{\"name\":\"Kirat\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\"},\"headline\":\"[Solved] How can i extract the info between &#8221; &#8221; ? C#\",\"datePublished\":\"2022-10-09T11:07:12+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-can-i-extract-the-info-between-c\/\"},\"wordCount\":342,\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"keywords\":[\"buffer\",\"c++\",\"serial-port\"],\"articleSection\":[\"Solved\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-can-i-extract-the-info-between-c\/\",\"url\":\"https:\/\/jassweb.com\/solved\/solved-how-can-i-extract-the-info-between-c\/\",\"name\":\"[Solved] How can i extract the info between \\\" \\\" ? C# - JassWeb\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#website\"},\"datePublished\":\"2022-10-09T11:07:12+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-can-i-extract-the-info-between-c\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/jassweb.com\/solved\/solved-how-can-i-extract-the-info-between-c\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-can-i-extract-the-info-between-c\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/jassweb.com\/solved\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[Solved] How can i extract the info between &#8221; &#8221; ? C#\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/jassweb.com\/solved\/#website\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"name\":\"JassWeb\",\"description\":\"Build High-quality Websites\",\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/jassweb.com\/solved\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\",\"name\":\"Jass Web\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"contentUrl\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"width\":693,\"height\":132,\"caption\":\"Jass Web\"},\"image\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\",\"name\":\"Kirat\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750\",\"contentUrl\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750\",\"caption\":\"Kirat\"},\"sameAs\":[\"http:\/\/jassweb.com\"],\"url\":\"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[Solved] How can i extract the info between \" \" ? C# - JassWeb","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jassweb.com\/solved\/solved-how-can-i-extract-the-info-between-c\/","og_locale":"en_US","og_type":"article","og_title":"[Solved] How can i extract the info between \" \" ? C# - JassWeb","og_description":"[ad_1] Try this demo, put it in a Main method of a console application (it uses Regex so you have to add line &#8220;using System.Text.RegularExpressions;&#8221;): string input = \"AT+CMGL=\"ALL\"n+CMGL: 0,\"REC READ\",\"+40728072005\",,\"12\/06\/29,13:04:26+12\"npassword,1,ON\"; var matches = Regex.Matches( input, @\"\"\"(?&lt;msisdn&gt;+d*)\"\",.*,\"\"(?&lt;date&gt;d{2}\/d{2}\/d{2},d{2}:d{2}:d{2}+d{2})\"\".*n+(?&lt;passwd&gt;[^,]*),(?&lt;itemno&gt;d*),(?&lt;command&gt;w*)\" , RegexOptions.Multiline); foreach (Match m in matches) { Console.WriteLine(m.Groups[\"msisdn\"].Value); Console.WriteLine(m.Groups[\"date\"].Value); Console.WriteLine(m.Groups[\"passwd\"].Value); Console.WriteLine(m.Groups[\"itemno\"].Value); Console.WriteLine(m.Groups[\"command\"].Value); } Console.ReadKey(); Basically, regular expression ... Read more","og_url":"https:\/\/jassweb.com\/solved\/solved-how-can-i-extract-the-info-between-c\/","og_site_name":"JassWeb","article_published_time":"2022-10-09T11:07:12+00:00","author":"Kirat","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kirat","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jassweb.com\/solved\/solved-how-can-i-extract-the-info-between-c\/#article","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-can-i-extract-the-info-between-c\/"},"author":{"name":"Kirat","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31"},"headline":"[Solved] How can i extract the info between &#8221; &#8221; ? C#","datePublished":"2022-10-09T11:07:12+00:00","mainEntityOfPage":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-can-i-extract-the-info-between-c\/"},"wordCount":342,"publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"keywords":["buffer","c++","serial-port"],"articleSection":["Solved"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/jassweb.com\/solved\/solved-how-can-i-extract-the-info-between-c\/","url":"https:\/\/jassweb.com\/solved\/solved-how-can-i-extract-the-info-between-c\/","name":"[Solved] How can i extract the info between \" \" ? C# - JassWeb","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/#website"},"datePublished":"2022-10-09T11:07:12+00:00","breadcrumb":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-can-i-extract-the-info-between-c\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jassweb.com\/solved\/solved-how-can-i-extract-the-info-between-c\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jassweb.com\/solved\/solved-how-can-i-extract-the-info-between-c\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/jassweb.com\/solved\/"},{"@type":"ListItem","position":2,"name":"[Solved] How can i extract the info between &#8221; &#8221; ? C#"}]},{"@type":"WebSite","@id":"https:\/\/jassweb.com\/solved\/#website","url":"https:\/\/jassweb.com\/solved\/","name":"JassWeb","description":"Build High-quality Websites","publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jassweb.com\/solved\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/jassweb.com\/solved\/#organization","name":"Jass Web","url":"https:\/\/jassweb.com\/solved\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/","url":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","contentUrl":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","width":693,"height":132,"caption":"Jass Web"},"image":{"@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31","name":"Kirat","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/","url":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750","contentUrl":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750","caption":"Kirat"},"sameAs":["http:\/\/jassweb.com"],"url":"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/"}]}},"_links":{"self":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/14926","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/comments?post=14926"}],"version-history":[{"count":0,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/14926\/revisions"}],"wp:attachment":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/media?parent=14926"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/categories?post=14926"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/tags?post=14926"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}