Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

GREP Code to Find Text Enclosed by $ Signs

Return to Member Forum

  • Author
    Posts
    • #14350172

      Hi folks

      A client has passed me a manuscript where all text to be italicised is enclosed in a pair of $ signs e.g. $italicise me$. This seems like a perfect job for GREP, but I cannot get it working consistently.

      Text between $ signs may include letters, digits, whitespaceewline, punctuation

      Goal is to find each instance, italicise the text, and remove the $ signs.

      My current GREP query is below, but it misses many instances:

      Find: (\$)(.+)(\$)
      Replace: $2 (Change format to “Italic” character style)

      Any help appreciated!

      Thanks
      Richard

    • #14350177
      David Blatner
      Keymaster

      Do you see any patterns of what it’s missing? Is it just new lines?
      I would simplify to \$(.+?)\$ and replace with $1

      • #14350183

        David

        Of all the GREP query suggestions I’ve had online, yours works the best, missing the fewest hits.

        The one that’s stumped all the suggested GREP queries so far is the passage of text attached at the end of this message. It’s the speaker of an endorsement in a book’s front matter, and a line break separates the speaker’s name from her bio.

        Most of the search hits won’t have any line breaks, so I think I’m OK to pick them up manually.

        Thanks again
        Richard

        ================

        This introduction to St Bernard through the lens of friendship opens up the twelfth-century monastic world of Bernard and of Aelred of Rievaulx and casts light on the struggles and joys of our lives today.
        $Reverend Dr Liz Carmichael MBE
        Emeritus Research Fellow, St John’s College, Oxford$

    • #14350179
      Dhafir Photo
      Participant

      Try this:
      in Find: \$([\S]+?)\$
      in Change: $1
      in Change Format: Italic

      • #14350180
        David Blatner
        Keymaster

        Wow! That’s great, Dhafir. Thank you. So, \S means “anything that isn’t a space” right? But means “any horizontal space”? Makes my head spin!

      • #14350193
        Dhafir Photo
        Participant

        Hello David!
        Yes that’s right
        \S All characters except Spaces, breaks, separators, right indent tab, and indent to here
        Horizontal whitespace including tab

    • #14350181

      Thank you both for getting back to me – I’ll give these a go!

    • #14350194
      Steve Davis
      Participant

      Funnily enough, this last week I was given some text for a book with markings (in Hebrew) like, [Z] ending with [ZZ] denoting a quotation to be indented. I tried to modify the above GREP without success, instead I did a multi find/change to apply my indent.

Viewing 4 reply threads
  • The forum ‘General InDesign Topics (CLOSED)’ is closed to new topics and replies.
Forum Ads