How to replace multiple spaces with a Single space in QuarkXPress using JavaScript

Discuss scripting using AppleScript in QuarkXPress 2015, 2016, 2017 & 2018.
Discuss scripting using JavaScript in QuarkXPress 2018.
Post Reply
User avatar
Sarbjit Singh
Quarkian
Quarkian
Posts: 406
Joined: 22 Jan 2009, 04:44
Location: India
Contact:

How to replace multiple spaces with a Single space in QuarkXPress using JavaScript

Post by Sarbjit Singh » 03 Aug 2018, 00:47

There are times when you wish to replace all two or more spaces (or any other white character) with a single space in QuarkXPress Layout. It is very easy to achieve using RegEx / Grep in QuarkXPress 2018, which ships with a default sample JavaScript called "Grep Search and Replace".

Here are the steps:

1. Open the JavaScript palette and go to Samples -> Typography.
2. Double click "Grep Search and Replace".
3. Enter this in the RegEx input: / +/g (It means "one or more spaces in plain English)
4. Enter a space in the Replacement String input. And, voila!!

Learn more about JavaScript RegEx syntax here: https://www.w3schools.com/jsref/jsref_obj_regexp.asp
Image

Post Reply

Return to “QuarkXPress 20xx: Scripting (AppleScript / JavaScript)”