{"id":3022,"date":"2018-04-01T00:01:50","date_gmt":"2018-04-01T07:01:50","guid":{"rendered":"http:\/\/c-for-dummies.com\/blog\/?p=3022"},"modified":"2018-04-08T08:10:15","modified_gmt":"2018-04-08T15:10:15","slug":"highlight-a-chunk-of-text","status":"publish","type":"post","link":"https:\/\/c-for-dummies.com\/blog\/?p=3022","title":{"rendered":"Highlight a Chunk of Text"},"content":{"rendered":"<p>Most of the common data formats, such as CSV, XML, and JSON, use plain text to store complex data or somehow interpret that plain text as something it&#8217;s not. The programmer&#8217;s job is to translate the plain text and generate the proper type of complex data.<br \/>\n<!--more--><br \/>\nWith formats such as XML and JSON, you can obtain a C library that does all the heavy lifting for you. For other formats, such as CSV, you can write yourself. (<a href=\"http:\/\/c-for-dummies.com\/blog\/?p=2315\">Click here<\/a> for my CSV Exercise from Feb. 2017.)<\/p>\n<p>For this month&#8217;s Exercise, I offer a simple type of data format or plain text processing as your challenge. The rule goes like this:<\/p>\n<ul>\n<li>The ^ character is a text formatting toggle.<\/li>\n<li>When ^ is encountered in a string of text, the following text is translated to UPPER CASE.<\/li>\n<li>When the ^ character is encountered again, text returns to lower case.<\/li>\n<\/ul>\n<p>Here are some sample runs:<\/p>\n<pre><code>Input: This is ^very^ important.\r\nOutput: This is VERY important.\r\n\r\nInput: You can ^even^ highlight ^multiple^ words.\r\nOutput: You can EVEN highlight MULTIPLE words.\r\n\r\nInput: And you can forget ^to turn it off.\r\nOutput: And you can forget TO TURN IT OFF.<\/code><\/pre>\n<p>If you use two ^ characters in a row, the format is turned on and off again, so your code doesn&#8217;t need a method for generating the ^ character itself as output:<\/p>\n<pre><code>Input: This is weird ^^^^^^output.\r\nOutput: This is weird output.<\/code><\/pre>\n<p>Your task is to write code that accepts a line of input, process that input, and convert text to UPPER CASE as shown in the above examples.<\/p>\n<p><a href=\"http:\/\/c-for-dummies.com\/blog\/?p=3039\">Click here<\/a> to view my solution, but please try this Exercise on your own before seeing what I did.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Transforming text is one of those dull things that computers enjoy doing. <a href=\"https:\/\/c-for-dummies.com\/blog\/?p=3022\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-3022","post","type-post","status-publish","format-standard","hentry","category-exercise"],"_links":{"self":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3022","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3022"}],"version-history":[{"count":7,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3022\/revisions"}],"predecessor-version":[{"id":3061,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3022\/revisions\/3061"}],"wp:attachment":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3022"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3022"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3022"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}