Hot answers tagged

11

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 whitespace, otherwise you'll be left with double spaces. so that's \s?\[[^]]*\] make sure the 'Change to' field is empty click 'Change All'


10

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 works on point text, area text and text on a path, and doesn't mind if non-text items are included in the selection. Note: there seems to be a bug where ...


6

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" field. (credits go to @Tobias Kienzler who suggested this)


4

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 even better <([^<>]*)>. But that matches the entire thing tough it has a matching group, you can use it to replace, but it does not alter the ...


4

Search for (?<=\w)\t and replace by a space (or \s ) FYI: This will strictly look for a tab placed after any word character.


3

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 look ahead") (?!\d).


3

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 engine does a match and continues its work form that point forward, never looking back. A similar things happens with GREP styles. Except it happens in reverse, ...


3

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 these questions on stack overflow you get a much faster answer. Now the grep of grep styles is different from the grep of search and replace (match versus replace ...


3

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 needed. A Character Style will need to be defined and then this will apply as a rule within your Paragraph Style. If you're using multiple styles, you need to do ...


3

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 characters before tab and apply a new character style set with no underlining: .+(?=\t) Solution 2 For an 'all-in-one' solution, try this: \u(?!.*\t) Which basically ...


3

Indeed a script can do it: //Main routine var main = function() { //==================VARS==================// var //The document doc = app.properties.activeDocument, //Find Grep Preferences in their current state fgp = app.findGrepPreferences.properties, //variables used for storing grep find values and items found, n, text, count, //A simple "...


3

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 previously defined expression


3

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 1234567 try ^ — \d{5,7}. Based on what you left in the comment for: — 1234567¶ you could use — \d{5,7}¶ or — \d{5,7}$. If you want to find anything after ...


3

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 ( // begin parenthesis 1 ( // begin parenthesis 2 [^\s]* // find zero or more non white spaces \s? // followed by zero or one white space ...


3

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 (the end of an uppercase word), wrapped in a positive lookbehind so we don't include the match \u - followed by any uppercase character [^\u\s] - followed by any ...


2

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 history. He or she only has to use the dropdown to access the expression. You should also save the search and replace expressions in a text file inside the project ...


2

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 recognizes a certain string pattern. But as this function only accepts strings and not dates or numbers I add a character "A" to the dates in a new column (C) ...


2

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 all the way up to the end of a paragraph. If you enable 'single line mode' using (?s), then the . wildcard will even match hard returns and so tries to select ...


2

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: Find: (\d)(?=(\d\d\d)+(:|\s)) Explanation match any digit followed by any number triplet of digits and : or any whitespace Replace $1~< Number and thin ...


2

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 explanation in layman's terms, especially the second answer. In any case the grep style does not allow matches over paragraph boundaries because its not a multi ...


2

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 strongly suggest you get rid of them, and apply a specific paragraph style to your title, with some space before. Assuming your document is already set up this way, ...


2

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

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++, vim, sublime text. Most *nix commandlines come equipped with a utilities for this. Such as grep or (egrep on most systems for regexp search), sed and awk ...


2

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: in grep find what: \t$ replace by (nothing): But off course what you ask can also be matched with the GREP: fid what: (\t[^\t]*)\t "Tab followed by ...


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