5 Replies Latest reply on Oct 31, 2016 4:57 PM by Peter Kahrel

    Scripting a Search and Replace, but it won't let me use special characters

    tkepner

      Hi, yall!

       

      I'm trying to change a document index that is partially complete (i.e., part way through the index creation I discovered I needed to add a non-breaking space between letters and numbers. I found a utility that lets me directly edit the index, but it won't let me insert the non-breaking space.

       

      Example (original index)

      LP 380-5. See GJ 1179 B.

      LP 380-6. See GJ 1179.

      LSPM J1709+4340. See HIP 83945.

      LTT 6988. See HIP 86057.

      LTT 10011. See HIP 428.

       

      I'm trying to insert the non-breaking space like so: (using an underline to show where I want the non-breaking space)"

      LSPM J1709+4340. See HIP_83945.

      LTT 6988. See HIP_86057.

      LTT 10011. See HIP_428.

       

      Here's the code I'm using:

       

      if (topic.name.match(/LSPM /) != null) {
      topic.name = topic.name.replace(/LSPM /g, "LSPM"\\S);
      topic.sortOrder = topic.sortOrder.replace(/LSPM /g, "LSPM"\\S);
      counter++;
      }
      

       

      I've tried every combination I can think of and I always end up with some variation of:

      LSPM J1709+4340. See HIPS83945.

      LTT 6988. See HIPS86057.

      LTT 10011. See HIPS428.

       

      or it fails to run. Tried using ~S no luck. Tried using \S, nope. Tried using \~S, uh-uh. Tried using ^S, -- nada. Even tried leaving off the quotes.

      What am I doing wrong? Or, better, what should I use instead?