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 to Standardize "e.g.," and "i.e.,"

Return to Member Forum

  • Author
    Posts
    • #84278
      Anonymous
      Inactive

      Hi all!

      I’m guessing this is an easy one, but I’m still having trouble.

      I’d like to take the most commonly used abbreviations used to express “for example” and “that is” also known as “e.g.,” and “i.e.,” respectively and change them to follow correct and consistent formatting throughout a file.

      So, it could read:

      eg. OR eg., OR eg OR e.g.

      All instances should be changed to:

      e.g.,

      Hints? I can usually get one thing to work at a time, but I’m still getting hung up. I’m testing it with eg. and all of the examples listed above and troubleshooting with the word “eggs” and I can’t get it to behave the way I think it should!

      Thanks!
      Elizabeth

    • #84281
      Matt Isaac
      Participant

      In GREP a vertical bar (shift+\) | is used to represent OR.
      so if you wanted exactly “eg. OR eg., OR eg OR e.g.” you could use [eg.|eg.,|eg|e.g.] and replace with e.g.,
      though the expression e\.?g\.?\,? replace with e.g., would also work.

      • #84282
        Matt Isaac
        Participant

        my first expression should be eg\.\,|eg\.|eg|e\.g\.

    • #84283
      Anonymous
      Inactive

      That finds the “eg” in knowlege, eggs, leg, etc.

      It doesn’t make sense to me, because your expression is where I started.

    • #84284
      Matt Isaac
      Participant

      you would then want to use lookarounds to find spaces so it won’t pick up eg inside other words
      (?<=)eg\.\,|eg\.|eg|e\.g\.(?=)

      • #84297
        Matt Isaac
        Participant

        Sorry i typed that on my phone last night without getting to verify the expression.. there should be parenthesis around (eg\.\,|eg\.|eg|e\.g\.) though if there are any instances where e.g. would not be enclosed by spaces on either side, (e.g.,, at the start or end of a paragraph) you may want to use (?<=[\L\U])(eg\.\,|eg\.|eg|e\.g\.)(?=[\L\U])

    • #84324
      Ari Singer
      Member

      This should be the code you’re looking for. It works for all the variations that you mentioned, including uppercase and lowercase.

      \<[eE]\.?[gG]\.?,?(?= )

      Following is the translation:

      At the beginning of a word (\<)
      Find an ‘e’ or ‘E’ ([eE])
      Followed by a period (\.) which may or may not be there (?)
      Folllowed by a ‘g’ or ‘G’ ([gG])
      Followed by a period (\.) which may or may not be there (?)
      Followed by a comma (,) which may or may not be there (?)
      Which is then followed by a space, but don’t capture that space, AKA Positive Lookahead ((?= ))

      • #84326
        Matt Isaac
        Participant

        Ari, I know this is not connected to the topic but i was wondering if you could tell me how to put strings of text into those boxes?

      • #84328
        Ari Singer
        Member

        Sure!

        If you have a basic understanding of HTML, then this will be easy. If not, it might take time to wrap your head around it, but bear with me.

        Any text that you want to display as code you have to enclose it in ‹code› tags.

        Example: Let’s say you want to take the following statement: “I am 23 years old”, and ‘codify’ the number ’23’ so it is displayed as code. So immediately before the ’23’ you have to type in an Opening Code Tag (‹code›) and immediately after the ’23’ you have to type in a Closing Code Tag (‹/code›). As you probably noticed, the difference between the opening tag and the closing tag is the forward slash (/) immediately before the tag name.

        So what you basically did is enclosed the number ’23’ in (‹code›) tags.
        So it will look like this: I am ‹code›23‹/code› years old. But when you submit the post, these tags or omitted from the actual text in your post, and instead you see the predefined code formatting on all the text that you enclosed in the ‹code› tags. So it will look like this by the rest of the world: I am 23 years old.

        I hope I was clear enough, if not feel free to ask me.

      • #84348
        Anonymous
        Inactive

        Your GREP is working fabulously, Ari. Thank you so much. Your explanation of each piece of the expression is extremely helpful. This helps me learn!

    • #84330
      Matt Isaac
      Participant

      Thanks, I am familiar with HTML. Though I’d never thought to use it in forums. I was actually thinking that it would be something to do with text editing for premium members.

      • #84331
        Ari Singer
        Member

        :)
        You can even use more functions. Such as ’em’ to italicize, ‘strong’ to bold, ‘ol’ or ‘ul’ for ordered lists and unordered lists respectively.

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