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 replace footnote>punctuation with punct>footnote

Return to Member Forum

  • Author
    Posts
    • #54587
      DMilson
      Participant

      Dear All,

      I would like to use GREP to search/replace all instances of footnote markers then punctuation:

      (~F)([;|,|.]) with $2$1.

      I'm using CS4 on Windows Bootcamp. Any suggestions as to why this doesn't work, or what will?

      Thanks in advance,

      David

    • #54593

      Hello,

      With GREP, it is impossible, because footnote marker can't be entered in the Change To box. You can do it with a script.

      I use this one :

      app.findGrepPreferences = null;
      app.changeGrepPreferences = null;
      app.findChangeGrepOptions.includeFootnotes = false;

      var pattern = “[,;.]+~F”;

      app.findGrepPreferences.findWhat = pattern;
      var finds = app.activeDocument.findGrep();
      for (var i = finds.length-1 ; i>=0 ; i–)
      {
      finds[i].characters.item(-1).move(
      LocationOptions.before,
      finds[i].characters.item(0)
      );
      }
      app.findGrepPreferences = null;
      app.changeGrepPreferences = null;

    • #54594
      Anonymous
      Inactive

      It seems to do it fine if you use Change All

      Weird

      But then you have to remove the full point from the end of the footnote

      So

      find: (~F)([[:punct:]])

      Change to $2$1

      <press change all)

      Then

      find: (?<=~F)[[:punct:]]

      Change:

      <press change all>

      I suppose it's a good idea to back up the file first – this might be more trouble than it's worth – then again it might not?

    • #54595

      “It seems to do it fine if you use Change All

      J'en apprends tous les jours, but I would like understand why.

      My example with the script is for french typo, for english you had to inverse: ~F[,;.]

      If you used two regex or more, Peter Kahrel's script (chain_grep_queries) is very very useful.

    • #54597
      Anonymous
      Inactive

      I don't know – it doesn't do it perfectly – that's why I suggest making a copy of the file first.

      I think it's a bug/

    • #59573
      AaronA
      Participant

      I tried same, and with a 'Change All' it does work, sort of. Actually it adds the same punctuation mark again on each replace. So where before you had 5.

      (where '5' is the footnote reference marker)

      you now have .5.

      So another search is needed to weed out the added punctuation. Not very time-efficient this way.

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