{"id":471,"date":"2012-02-09T18:17:16","date_gmt":"2012-02-10T02:17:16","guid":{"rendered":"http:\/\/thelawlers.com\/Blognosticator\/?p=471"},"modified":"2012-02-09T18:17:16","modified_gmt":"2012-02-10T02:17:16","slug":"another-grepping-story","status":"publish","type":"post","link":"https:\/\/thelawlers.com\/Blognosticator\/?p=471","title":{"rendered":"Another GREPping story"},"content":{"rendered":"<p><a href=\"https:\/\/thelawlers.com\/Blognosticator\/wp-content\/uploads\/2011\/08\/Blognosticator-Head.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-25\" title=\"Blognosticator Head\" src=\"https:\/\/thelawlers.com\/Blognosticator\/wp-content\/uploads\/2011\/08\/Blognosticator-Head.png\" alt=\"\" width=\"252\" height=\"115\" \/><\/a><br \/>\nFor those stalwart folks who follow this blog, you know that I am a GREP enthusiast. I use it as often as possible; I treat it as mental calisthenics; I look for opportunities to GREP my way out of every problem.<\/p>\n<p>For those new to the topic, GREP is a search method that is found in some of the best word processors (Word does not have it); InDesign has it. Text Wrangler does. My favorite, Tex-Edit Plus has it, but unfortunately that program is not compatible with the latest operating system from Apple: Lion. I\u2019m sticking with Snow Leopard until I can solve this problem (I\u2019m teaching myself GREP in Text Wrangler).<\/p>\n<p>GREP is an acronym for <em>Graphical Regular Expressions.<\/em> It has been around for decades, and was originally found in UNIX. UNIX purists spit at InDesign\u2019s unconventional application of GREP, saying that it\u2019s not pure GREP. I don\u2019t care; it\u2019s delightful.<\/p>\n<p>GREP allows you and me to search for abstract items, as opposed to searching for a specific word or combination of letters. The idea is that you an search a large document, looking for the word \u201cChapter\u201d followed by any number, followed by a carriage return, and change its Paragraph Style to make it a Chapter Head.<\/p>\n<p>Or, you can take a list of names that is last-name-first, and make it first-name-first. I do this a lot with roll sheets at the University.<\/p>\n<p>My students love GREP because they work a lot with book-length manuscripts, building them into finished books for print publishing and ePub export (more on that in a blog tomorrow). One of my students approached me yesterday to solve a problem with Pride and Prejudice. Her manuscript is over 700 pages in length, and she wanted to know if GREP could style just the chapter heads as I described above. Click-click, beep! It was done. I enjoyed those clicks and beeps immensely!<\/p>\n<p>Just minutes later (this is my Advanced Typography class, so it\u2019s in the heart of their studies this time of year) another student approached me to solve a problem I have encountered before. The text she is working on has emphasized strings in ALL CAPS. She wants them in Italics, lower-case.<\/p>\n<p>InDesign has a menu item for changing case, but it can\u2019t do it as part of a find-and-replace string (which is a shame).<\/p>\n<p>I searched Adobe\u2019s web site, and the Interwebs in general, and in a few minutes I found a nice Javascript written by Thomas Silkj\u00e6r, a fellow in Denmark that can change CAPS into lower-case, or vice-versa. It also does Small Caps.<\/p>\n<p>The best part of this Javascript is that it uses GREP as its search criteria.<\/p>\n<p>I downloaded the Javascript, which arrived in Firefox as a text file. I saved it, changed its suffix to .jsx, then stuck it into the Scripts folder in InDesign (I didn\u2019t even have to restart InDesign). In a few seconds it appeared in my Scripts panel in InDesign, and I got it working just a few minutes later.<\/p>\n<p>The manuscript is long, and it has many ALL CAPS sections in it. The GREP function for finding all caps is:<\/p>\n<p><a href=\"https:\/\/thelawlers.com\/Blognosticator\/wp-content\/uploads\/2012\/02\/First-GREP-string.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-472\" title=\"First GREP string\" src=\"https:\/\/thelawlers.com\/Blognosticator\/wp-content\/uploads\/2012\/02\/First-GREP-string.png\" alt=\"\" width=\"85\" height=\"40\" \/><\/a><\/p>\n<p>\u2026which translated into English is \u201cFind any upper-case character one or more times followed by a space, and store it in a variable called $1.\u201d<\/p>\n<p>I entered this into the script, and clicked OK, and it instantly converted almost all the ALL-CAPS into lower-case letters. When I say almost all, I mean it missed those words that are hyphenated into a compound-expression, words followed by a comma, or a period.<\/p>\n<p>The fix for that was easy. I modified the GREP search string to:<\/p>\n<p><a href=\"https:\/\/thelawlers.com\/Blognosticator\/wp-content\/uploads\/2012\/02\/Second-GREP-String.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-473\" title=\"Second GREP String\" src=\"https:\/\/thelawlers.com\/Blognosticator\/wp-content\/uploads\/2012\/02\/Second-GREP-String.png\" alt=\"\" width=\"135\" height=\"40\" \/><\/a><\/p>\n<p>\u2026which means: \u201cFind any upper-case character one or more times, followed by either a space, a comma, a hyphen or a period, and store it in a variable named $1.\u201d<\/p>\n<p>This solved the problem for the manuscript.<\/p>\n<p>Except it also changed all the article I \u201cwords\u201d into lower-case i\u2019s. <em>Oops!<\/em> I suddenly became i.<\/p>\n<p>I fixed those quickly with a standard text search \u201clook for space followed by lower-case i, followed by space, replacing with space-Cap-I-space.\u201d<\/p>\n<p>But this left my GREPping mind unsettled, and I sweated all night thinking about a more elegant solution.<\/p>\n<p>Then I spent far too long today trying to figure out how to use GREP\u2019s negative look-ahead tool to say, \u201cFind one or more cap letters \u2013 other than the letter I \u2013 followed by a space, but followed by a comma, etc., and change it into lower-case.\u201d<\/p>\n<p>So far I haven\u2019t succeeded in making this work. BUT I PROMISE I WILL (caps intentional).<\/p>\n<p>When I do, I will post it here.<\/p>\n<p>Happy grepping to you!<\/p>\n<p>Thank you to Thomas Silkj\u00e6r for<a title=\"Change case script for InDesign\" href=\"http:\/\/indesigning.net\/search-and-change-case\"> his script.<\/a> I made a donation on PayPal for his work, though I couldn\u2019t read much of the Danish as I did it. Is 40,000 Kroners a lot?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For those stalwart folks who follow this blog, you know that I am a GREP enthusiast. I use it as often as possible; I treat it as mental calisthenics; I look for opportunities to GREP my way out of every &hellip; <a href=\"https:\/\/thelawlers.com\/Blognosticator\/?p=471\">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":[1],"tags":[],"class_list":["post-471","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/thelawlers.com\/Blognosticator\/index.php?rest_route=\/wp\/v2\/posts\/471","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=471"}],"version-history":[{"count":1,"href":"https:\/\/thelawlers.com\/Blognosticator\/index.php?rest_route=\/wp\/v2\/posts\/471\/revisions"}],"predecessor-version":[{"id":474,"href":"https:\/\/thelawlers.com\/Blognosticator\/index.php?rest_route=\/wp\/v2\/posts\/471\/revisions\/474"}],"wp:attachment":[{"href":"https:\/\/thelawlers.com\/Blognosticator\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=471"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thelawlers.com\/Blognosticator\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=471"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thelawlers.com\/Blognosticator\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=471"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}