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 the references

Return to Member Forum

  • Author
    Posts
    • #57847
      Hopsa Rijnen
      Member

      Hi all, i was fairly content with my ability tro grep things around.

      Helas, i wasn't that great at it

      Below i got ya'll some sample text which i grep-styled withe the following query: (d+[;]*[-]*d*)

      Now that covers the most of the entries in the thesis. Except the longer ones like (6;7;22-30)

      I know grep can do this, but i'm fresh out of ideas.

      Can one of you enlighten me?

      Sample text:

      references (14-19), although a (1;2) survival benefit during the first two blahblahthoughblah (14;20;21). With regard to quality of humptidumpty (6;7;22-30). sat on a wall of some kind and fell off inexplicitely (7;25;26;29;30;30;31),

      Your help is greatly appreciated!

      Hopsa

    • #57848
      Hopsa Rijnen
      Member

      it misses the backslashes before the ( and the d's and the )

    • #57850

      The trick is to recognize the actual underlying pattern:

      A number between parentheses, OR

      a number range, indicated by

      a number, a dash, a number, OR

      any of the above repeated and separated by semicolons.

      Without testing, this ought to do the job (I inserted double backslashes, which seems to defeat the slash-eating imp :D ):

      (d+(-d+)?(;d+(-d+)?)*)

      Notice that the 2nd half is exactly the same as the first, but with a semicolon in front and to be repeated zero or more times.

    • #57851
      Hopsa Rijnen
      Member

      Jongware!

      You are definately the king of [GREP|scripting]

      I failed the patternrecognizing and couldn't come up with the right one.

      Just for my understanding the question mark in between makes the OR statement?

      Or does it state the any of the above repeated?

      EDIT: Yep got it!

      It states ofcourse whats in between the extra parenthesis! OR is that it is in separated inbetween parenthesis)

      Thanks a million!

      Hopsa (jongware fanboy ;:-) )

    • #57858

      It states ofcourse whats in between the extra parenthesis! OR is that it is in separated inbetween parenthesis)

      Yeah, you would put a ? right after a single code if you want that one once or not at all — as in “Figures?”, which is a neat way of looking for both “Figure” and “Figures”. Right after a parenthesized group it works on that entire group.

      So in this case it looks for (decimals), then optionally (-decimals), meaning that it will match “(10)” and “(10-22)” but not “(10-)” or “(-10)”.

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