{"id":776,"date":"2011-02-23T11:33:59","date_gmt":"2011-02-23T16:33:59","guid":{"rendered":"http:\/\/www.jaimerios.com\/?p=776"},"modified":"2011-02-23T11:33:59","modified_gmt":"2011-02-23T16:33:59","slug":"performing-a-large-search-and-replace","status":"publish","type":"post","link":"https:\/\/jaimerios.com\/?p=776","title":{"rendered":"Performing a large search and replace"},"content":{"rendered":"<p>Thanks to my co-worker for showing me this really cool trick in TextMate!<\/p>\n<p>I have this project I&#8217;m working on where I need to represent enum values as text for analysis purposes. The enum though is not set up to be easily iterated over (<a href=\"http:\/\/www.ddj.com\/184403955\" target=\"_blank\" rel=\"noopener\">Dr. Dobbs<\/a>) (<a href=\"http:\/\/groups.google.com\/group\/comp.lang.c++\/msg\/d9f99ea5f6787c86\" target=\"_blank\" rel=\"noopener\">James Kanze<\/a>), so I added a stream operator to do the job.<\/p>\n<p>Now, using TextMate, it&#8217;s easy to use the Macro recorder to perform a text insert operation over a small enum. However, I came across a large one that would make this process way too cumbersome.<\/p>\n<p><code>enum {<br \/>\nkFirstConstant\t\t\t= 0x001000,<br \/>\nkSecondConstant\t\t= 0x001002,<br \/>\nkThirdConstant\t\t= 0x001004,<br \/>\n[...]<br \/>\nkTwoHundrethConstant\t= 0x001216,<br \/>\n};<\/code><\/p>\n<p>Thanks to my co-worker, he showed me how I can easily modify my text using <a href=\"http:\/\/macromates.com\/\" target=\"_blank\" rel=\"noopener\">TextMate<\/a>&#8216;s Search and Replace feature on left-justified code:<\/p>\n<p><strong>Find<\/strong>:<br \/>\n<code>^(\\w+)(.+)$<\/code><\/p>\n<p><strong>Replace<\/strong>:<br \/>\n<code>else if (enumvalue == $1)<br \/>\n\\tstringrep = \"$1\";<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Thanks to my co-worker for showing me this really cool trick in TextMate! I have this project I&#8217;m working on where I need to represent enum values as text for analysis purposes. The enum though is not set up to be easily iterated over (Dr. Dobbs) (James Kanze), so I added a stream operator to &#8230; <a title=\"Performing a large search and replace\" class=\"read-more\" href=\"https:\/\/jaimerios.com\/?p=776\" aria-label=\"Read more about Performing a large search and replace\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,31],"tags":[189,399,441],"class_list":["post-776","post","type-post","status-publish","format-standard","hentry","category-coding","category-tip","tag-enum","tag-search-and-replace","tag-textmate"],"_links":{"self":[{"href":"https:\/\/jaimerios.com\/index.php?rest_route=\/wp\/v2\/posts\/776","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jaimerios.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jaimerios.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jaimerios.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jaimerios.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=776"}],"version-history":[{"count":0,"href":"https:\/\/jaimerios.com\/index.php?rest_route=\/wp\/v2\/posts\/776\/revisions"}],"wp:attachment":[{"href":"https:\/\/jaimerios.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=776"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jaimerios.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=776"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jaimerios.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=776"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}