Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

RegExp for Thin Space

Engaged ,
Nov 11, 2008 Nov 11, 2008
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?
--
Noel
TOPICS
Scripting
1.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 11, 2008 Nov 11, 2008
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 ();

regards,
gregor
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Nov 11, 2008 Nov 11, 2008
Hi,
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.
Loic
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 11, 2008 Nov 11, 2008
LATEST
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
http://www.night-ray.com/regex.pdf
has to be treated specially?
--
Noel
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines