{"id":483,"date":"2012-02-26T11:27:30","date_gmt":"2012-02-26T19:27:30","guid":{"rendered":"http:\/\/thelawlers.com\/Blognosticator\/?p=483"},"modified":"2012-02-26T11:30:35","modified_gmt":"2012-02-26T19:30:35","slug":"more-on-my-obsession-with-grep","status":"publish","type":"post","link":"https:\/\/thelawlers.com\/Blognosticator\/?p=483","title":{"rendered":"More on my obsession with GREP"},"content":{"rendered":"<p><a href=\"https:\/\/thelawlers.com\/Blognosticator\/wp-content\/uploads\/2011\/07\/Blognosticator-Head.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5\" title=\"Blognosticator Head\" src=\"https:\/\/thelawlers.com\/Blognosticator\/wp-content\/uploads\/2011\/07\/Blognosticator-Head.png\" alt=\"\" width=\"252\" height=\"115\" \/><\/a><\/p>\n<p>In a blog post a few days back, I was confounded by the problem of converting ALL CAPS into lower case letters. Using a Javascript that I licensed from a Danish programmer, I was able to make the case change, but the GREP search was also converting articles like <em>I<\/em> and <em>A<\/em> into lower case, and that was creating a new (but easily soluble) problem.<\/p>\n<p>One of my former students, Jeff Bauer, sent me a fix that he found on a programmer\u2019s web site. It solves a related problem using the same Javascript: not changing Roman Numerals into lower-case letters. Curiously, that solution also solves the articles problem I was having.<\/p>\n<p>Thank you Jeff for submitting the solution to my problem!<\/p>\n<p>Let\u2019s take a look at how it\u2019s done. I had wrestled with this problem, and had failed to find a solution because I do not know how to use \u201cnegative look-aheads\u201d in GREP. I tried, believe me, but I failed to solve the problem.<\/p>\n<p>The solution Jeff sent is complex but elegant: \\b(?![LXIVCDM]+\\b)([A-Z]{2,})\\b<\/p>\n<p>Huh? This uses both a negative look-ahead, and a little-documented GREP feature that says \u201cthis has to be at least two characters in length. It\u2019s the part in series braces {}.<\/p>\n<p>Here is a diagram of how it works:<\/p>\n<p><a href=\"https:\/\/thelawlers.com\/Blognosticator\/wp-content\/uploads\/2012\/02\/GREP-caps-to-LC-string.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-484\" title=\"GREP caps to LC string\" src=\"https:\/\/thelawlers.com\/Blognosticator\/wp-content\/uploads\/2012\/02\/GREP-caps-to-LC-string.png\" alt=\"\" width=\"429\" height=\"264\" srcset=\"https:\/\/thelawlers.com\/Blognosticator\/wp-content\/uploads\/2012\/02\/GREP-caps-to-LC-string.png 429w, https:\/\/thelawlers.com\/Blognosticator\/wp-content\/uploads\/2012\/02\/GREP-caps-to-LC-string-300x184.png 300w\" sizes=\"auto, (max-width: 429px) 100vw, 429px\" \/><\/a><\/p>\n<p>My test document is a page of InDesign-generated pseudo-Latin into which I inserted a handful of all-caps examples, as well as a few cap-I and cap-A situations. I also threw-in Roman numerals to test the advertised function of the string.<\/p>\n<p><a href=\"https:\/\/thelawlers.com\/Blognosticator\/wp-content\/uploads\/2012\/02\/Caps-in-text.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-485\" title=\"Caps in text\" src=\"https:\/\/thelawlers.com\/Blognosticator\/wp-content\/uploads\/2012\/02\/Caps-in-text.jpg\" alt=\"\" width=\"467\" height=\"908\" srcset=\"https:\/\/thelawlers.com\/Blognosticator\/wp-content\/uploads\/2012\/02\/Caps-in-text.jpg 467w, https:\/\/thelawlers.com\/Blognosticator\/wp-content\/uploads\/2012\/02\/Caps-in-text-154x300.jpg 154w\" sizes=\"auto, (max-width: 467px) 100vw, 467px\" \/><\/a><\/p>\n<p><em><span style=\"color: #0000ff;\">Above: the text before I ran the search for all-caps.<\/span><\/em><\/p>\n<p>The search string works fine, except for one exception where it fails with a string of all-caps letters preceded by a hyphen.<\/p>\n<p><a href=\"https:\/\/thelawlers.com\/Blognosticator\/wp-content\/uploads\/2012\/02\/Successful-GREP.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-486\" title=\"Successful GREP\" src=\"https:\/\/thelawlers.com\/Blognosticator\/wp-content\/uploads\/2012\/02\/Successful-GREP.jpg\" alt=\"\" width=\"467\" height=\"908\" srcset=\"https:\/\/thelawlers.com\/Blognosticator\/wp-content\/uploads\/2012\/02\/Successful-GREP.jpg 467w, https:\/\/thelawlers.com\/Blognosticator\/wp-content\/uploads\/2012\/02\/Successful-GREP-154x300.jpg 154w\" sizes=\"auto, (max-width: 467px) 100vw, 467px\" \/><\/a><\/p>\n<p><em><span style=\"color: #0000ff;\">Above is the same text after I ran the script with the new GREP string. Notice the single word that is still capitalized, a compound word.<\/span><\/em><\/p>\n<p>I guess that\u2019s my <em>next<\/em> challenge.<\/p>\n<p>_____<\/p>\n<p>I\u2019m writing a new book about printing processes and prepress. Click on the link below to give me your e-mail address, and I will let you know when the book is published (target date is March, 2012).<\/p>\n<p><a title=\"My new book\" href=\"http:\/\/www.thelawlers.com\/BookInfo.html\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-230\" title=\"My New Book\" src=\"https:\/\/thelawlers.com\/Blognosticator\/wp-content\/uploads\/2011\/10\/My-New-Book1.png\" alt=\"\" width=\"291\" height=\"119\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In a blog post a few days back, I was confounded by the problem of converting ALL CAPS into lower case letters. Using a Javascript that I licensed from a Danish programmer, I was able to make the case change, &hellip; <a href=\"https:\/\/thelawlers.com\/Blognosticator\/?p=483\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-483","post","type-post","status-publish","format-standard","hentry","category-imposition-and-pagination"],"_links":{"self":[{"href":"https:\/\/thelawlers.com\/Blognosticator\/index.php?rest_route=\/wp\/v2\/posts\/483","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thelawlers.com\/Blognosticator\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thelawlers.com\/Blognosticator\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thelawlers.com\/Blognosticator\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thelawlers.com\/Blognosticator\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=483"}],"version-history":[{"count":4,"href":"https:\/\/thelawlers.com\/Blognosticator\/index.php?rest_route=\/wp\/v2\/posts\/483\/revisions"}],"predecessor-version":[{"id":489,"href":"https:\/\/thelawlers.com\/Blognosticator\/index.php?rest_route=\/wp\/v2\/posts\/483\/revisions\/489"}],"wp:attachment":[{"href":"https:\/\/thelawlers.com\/Blognosticator\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=483"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thelawlers.com\/Blognosticator\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=483"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thelawlers.com\/Blognosticator\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=483"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}