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 simple query

Return to Member Forum

  • Author
    Posts
    • #60797
      nicds
      Member

      Hi

      I have a really simple query that is baffling me.

      I want to change all spaces to tabs after numbers with a point.

      Eg:

      1. Life skills

      So after 1. there needs to be tab instead of a space.

      I know how to find them all, but what do I insert in the replace section?

      I've searched some GREP sites, but the formulas are way more advanced than I need.

      Apologies if this has already been asked somewhere… I searched the forum and could not find it.

      Thanks

    • #60798

      Only for today I'll offer you not one but two ways.

      Search for

      (d.)[a single space]+

      Replace with

      $1t

      The parentheses mark “Found group #1”, and you can insert this back again in the Replace expression with “$1”. This feature is particularly useful when you need to swap two items around (in Replace you can use something like “$2 $1”) or want to repeat something (simply write “$1 $1 $1 $1” to get five copies of whatever you found).

      There is a more advanced way, though: you can search for one or more spaces and then use a Positive Lookbehind to ensure these are preceded by a digit plus a period. The advantage is the expression doesn't “touch” the digits, only (I believe it is an advantage, but for reasons more spiritual rather than practical. It may also run a bit faster.).

      Search for

      (?<=d.)[a single space]+

      Replace with

      t

    • #60799
      nicds
      Member

      Thanks you so much. You're a genius!!

      I need to learn more about GREP – it's such a powerful tool.

      Thanks again.

    • #60814
      nicds
      Member

      Just noticed something that happens when running this GREP.

      Once run, it deletes the first part of some words.

      I've extracted a small section:

      Before

      Use prefixes to change each word into a verb.

      1. able

      2. custom

      3. labour

      4. power

      5. trust

      6. firm

      After

      Use prefixes to change each word into a verb.

      1. ble

      2. ustom

      3. bour

      4. ower

      5. trust

      6. firm

      It only does it on single list words… sentences seem to be fine. And as you can see not all single words.

      Any idea why this happens? What am I doing wrong?

      Thanks

    • #60825

      That oughtn'tn'tt've happened. Which of the two GREPs are you using? (They don't mix!)

    • #60940

      I have had a character unexpectedly deleted in an S&R when using the “FindChangebyList” script I've been using for years. Our editors hard code quotation marks to indicate which are opening (<”) and which are closing (“). In a recent book of 8 chapters, all the chapters S&R'd fine using that script except chapter 3. In the middle of chapter 3 that S&R began inserting an ornament instead of an opening quotation mark and deleting the first character of the following word. This is not an InDesign issue or an issue with the script—it must be a Word artifact that was accidentally replicated when the copyeditor did their own S&R to code the quotation marks in that chapter.

      My current Word clean-up procedure is to open all the files in Word, save them as Word .htm files, and then resave them as Word .rtf files. Saving to .htm is what cleans up the random “stuff,” re-saving as .rtf is just my preference, I could probably re-save as .doc or .dox at that point but I haven't tested that. The trip through .htm seems to solve many mysterious formatting errors such as the S&R error above and the inexplicable proliferation of superscript from some point in a file all the way to the end.

      If your original text came from a Word file, I would suggest that you save that file as Word .htm and then .rtf and then reimport it into InDesign (or at least the list portion) to see if the S&R error came from the underlying text.

      Also,

      (?<=d.)[a single space]+

      will find a number followed by a period and space anywhere, not just at the beginning of a list so don't do a “Replace All” with it.

    • #60952

      Also,

      (?<=d.)[a single space]+

      will find a number followed by a period and space anywhere, not just at the beginning of a list so don't do a “Replace All” with it.

      Yeah — change it to

      (?<=^d.)[space)

      to anchor it to the start of a paragraph.

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