3 Replies Latest reply on Nov 11, 2008 4:02 PM by Ildhund

    RegExp for Thin Space

    Ildhund Level 3
      Sorry to pester you with another newbie question. Try as I might, I
      can't seem to hit on the right syntax to find thin spaces (for
      example) in a string and replace them with nothing. I've tried every
      conceivable combination of [], '' and \ with ~< but I still get
      little boxes where the thin space was instead of nothing, and I
      can't find any alternative to ~< for Thin Space.
      myString = myString.replace(/~Will anyone point me in the right direction?
        • 1. Re: RegExp for Thin Space
          Level 1
          hi noel,

          you're using the javascript string replace function. there you cant use the indesign shortcuts. you need the real thin space here (i haven't tested but i guess it will work with copy and paste) or check out the unicode representation and use it with \u.

          i would recomend using the built in indesing grep search and replace. which is in short:

          // reset
          app.changeGrepPreferences = NothingEnum.nothing;
          app.findGrepPreferences = NothingEnum.nothing;

          app.findGrepPreferences.findWhat = "~<";
          app.findGrepPreferences.changeTo = "";
          app.activeDocument.changeGrep ();

          • 2. Re: RegExp for Thin Space
            Loic.Aigon Adobe Community Professional
            Found this approach on Dave Saunders's blog :

            var myRG = new RegExp("\u2009", "g");
            myString = myString.replace(myRG, '');

            As you see, I needed to specify the unicode code for thin space. As gfellenz said, using "~<" did not work.
            • 3. Re: RegExp for Thin Space
              Ildhund Level 3
              I'm very grateful to you both. I'm manipulating strings to be used
              outside of the document, so I have to use a script. The Unicode
              solution works fine, of course. Can I assume that any regex I find
              in the F&R GREP box that isn't in Gordon McKinney's quick reference
              guide at
              has to be treated specially?