11
votes
Accepted
How to do a wildcard / GREP / regex find-replace in Illustrator?
I gone done made a script for that. I've tested it in Illustrator CS6 on Mac and on Windows.
It does a regex find-replace on text in the selected items, or on all text if nothing is selected.
It ...
11
votes
Accepted
InDesign: how to remove everything between square brackets
You don't need to script this, just
hit Ctrl+F and switch to the 'GREP' tab
type \[[^]]*\] in the 'Find what' field
or type the same thing with an \s? added in front to also remove any preceding ...
6
votes
Accepted
InDesign: grep style to move single i words to next line
Create a character style and set it to "No break".
Edit your existing paragraph style, go to the GREP Style tab, choose the character style you created above and type (?<=\s)i\W+ in the "To Text" ...
4
votes
Change HTML tag styles with GREP in InDesign
Its not a good idea to parse HTML with regular expressions (GREP). ;(
Why are you esscaping the < and > chars? they should have no specific meaning in regular expressions. Try <(.*?)> or ...
4
votes
Accepted
InDesign GREP: not replacing the search
Search for
(?<=\w)\t
and replace by a space (or \s )
FYI: This will strictly look for a tab placed after any word character.
4
votes
Accepted
InDesign: how to find all numbers followed by a period
Use
\s(\d\.) in the 'Find what' field. \s is the space and (\d\.) defines an expression made up of a digit and a full stop
and $1 in the 'Change to' field. this removes the space and keeps the ...
3
votes
Accepted
Find unwanted paragraph marks (GREP, find, replace, script)
Two criteria for your Find:
Use this GREP search: \r(?!\d)
And specify "Paragraph Style 1" in the Find Format field.
GREP search looks for a paragraph mark \r, not followed by a digit (a "negative ...
3
votes
InDesign: how to apply styles to specific words/phrases
An automated way is to use GREP Styles via the Paragraph Style options. This feature is automatic so every time the phrase appears it will instantly apply the formatting without any manual search ...
3
votes
inDesign GREP styles
The regular expression engine chooses the first match that's possible. For example the regular expression foo|foo bar will never match foo bar simply because it will always match foo first. See the ...
3
votes
Accepted
How can I use GREP to get all text between the third and fourth underscore in a file name?
Regular expressions is a general programming concept and by no means only something found in InDesign (in pretty much fact every programming language out there has regexp support). So you can ask ...
3
votes
Accepted
Underline all initials after a tab
Solution 1
You can achieve this with 2 Grep styles (in the right order).
First catch all uppercase characters and apply underline character style to this first query: \u+
Then catch all ...
3
votes
Use GREP to replace multiple characters
Indeed a script can do it:
//Main routine
var main = function() {
//==================VARS==================//
var
//The document
doc = app.properties.activeDocument,
//Find Grep Preferences in ...
3
votes
Accepted
GREP terms for searching a dash followed by a string of numbers and a paragraph break
Your question is somewhat unclear but you could do the following in InDesign with GREP:
— 12345
try: ^ — \d{5}
— 123456
try: ^ — \d{6}
— 1234567
If you're looking for a range from 12345 to ...
3
votes
Accepted
How to search for the Nth (2nd, 3rd, etc.) white space in a paragraph?
Solution
Find what
(([^\s]*\s?){n})\s(.*\r) where n is a number of your choice.
Change to
$1text$3 where text is the text you want to change the nth space to.
Explanation
Find what
( /...
3
votes
Accepted
Indesign GREP: Find sentence until first occurence of specific character
Never mind. ##.+?## is the answer. Sometimes after ages of struggle you simply have to ask the question to suddenly find the answer yourself.
+? keeps the search to the first complete sequence.
3
votes
How to use GREP to only style a part of the expression?
This should work in your case:
(?<=\u )\u[^\u\s].*Favorite
or the more general:
(?<=\u )\u[^\u\s].*\l
Explanation
(?<=\u ) - first we search for any uppercase character followed by a space (...
2
votes
InDesign, Grep and Syntax Highlighting
Don't try to match generic XML with regexp. It will not work in many cases, use a XML parser instead and export the result. See:
Why it's not possible to use regex to parse HTML/XML: a formal ...
2
votes
Indesign grep: Grab everything but
Here is how I solved it.
First I moved back to my Google spreadsheet using Regex.
I did the thing in 2 steps which could probably be joined together.
I want to use the =REGEXREPLACE function that ...
2
votes
Using grep to finding long digit series and inserting thin spaces into them
There is a bug in the matching engine (at least in my indesign) we will fix this first.
Find:
(.)\Z
Replace
$1:
Replace All
Ok now we have a anchor at the end of story. Now for the magic:
...
2
votes
GREP style after double line break
You should never, ever use multiple line breaks... If your text reflows, line breaks could be located on top of a column or a frame, which is definitely not what you want (see example below).
I ...
2
votes
Accepted
Indesign GREP search includes too much
By default, GREP is greedy: as long as there is a match to be found further on, it will grab as much as possible. Since the . does not match (by default) a hard return character, it will usually scan ...
2
votes
Underline all initials after a tab
It’s all depends of your actual text...
If you just have a bunch of lines with Acronymes you can use this simple one.
\u(?=\l+)
2
votes
Accepted
Is there an environment with GREP outside of InDesign?
They are called regular expressions (regexp).
Most good editors have regexp support. Pesonally i use Scite, but most good text editors have this support these include but are not limited to notepad++...
2
votes
Targeting every second tab using Grep and then changing it to nothing
OK, there are 2 tactics that you can take here. You could match what you ask, its a bit tricky it would be easier to match "line ending in tab", which would solve your current situation more easily:
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
grep × 90adobe-indesign × 84
indesign-scripting × 15
paragraph-styles × 13
character-styles × 13
automation × 5
regex × 5
batch-processing × 4
formatting × 3
adobe-illustrator × 2
text × 2
typesetting × 2
creative-cloud × 2
book × 2
javascript × 2
publishing × 2
paragraph × 2
footnotes × 2
color × 1
fonts × 1
font-design × 1
html × 1
script × 1
style × 1
data-merge × 1