Hot answers tagged

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 ...
user avatar
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 ...
user avatar
  • 27.5k
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" ...
user avatar
  • 27.5k
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 ...
user avatar
  • 55.3k
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.
user avatar
  • 4,553
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 ...
user avatar
  • 27.5k
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 ...
user avatar
  • 1,481
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 ...
user avatar
  • 55.3k
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 ...
user avatar
  • 55.3k
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 ...
user avatar
  • 27.5k
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 ...
user avatar
  • 4,553
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 ...
user avatar
  • 691
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 ...
user avatar
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 ( /...
user avatar
  • 19.1k
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.
user avatar
  • 373
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 (...
user avatar
  • 19.1k
2 votes

How can I use GREP in InDesign to swap numbers then nest, then repeat

GREP Search and Replace is definitely the simple way to go. You can set up the expression for the designer once, and InDesign will always remember it and keep it available in the search/replace ...
user avatar
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 ...
user avatar
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 ...
user avatar
  • 4,178
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: ...
user avatar
  • 55.3k
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 ...
user avatar
  • 55.3k
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 ...
user avatar
  • 4,553
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+)
user avatar
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++...
user avatar
  • 55.3k

Only top scored, non community-wiki answers of a minimum length are eligible