Find/replace style cell with GREP

Hi all, (my first post here)

I found a script very useful on this forum to find/replace cell styles in an array. I adapted the script using Peter Kahrel ebook for use with a GREP query.

I've linked to a spreadsheet in InDesign CC 2014 I want to highlight the cell of new products that contain the value [Y].

When I run the script below, I get random results.

myDoc = app.activeDocument var

app.findGrepPreferences = app.changeGrepPreferences = null

app.findGrepPreferences.findWhat = "\[\u\"]

var myFound = myDoc.findGrep)

for (i = 0; i < myFound.length; i ++)

{

If (. parent.constructor.name myFound [i] == "Cell")

{

. parent.appliedCellStyle myFound [i] = "New_Product_Cell".

}

}

Modify the script that I wrote above.

Otherwise your discovery is just '[u]' ==> multi-ad found is--> Direct manufacturer name


Jarek

Tags: InDesign

Similar Questions

  • Find the last characters with grep

    I'm lousy with grep and didn't find the solution with google, we will so ask here (help me, please...)

    I need to find the last 7 characters in a paragraph and assign a character style "not break". I know that all the rest, but what is the string to find the last 7 characters (white space included, numbers and letters).

    Thanks in advance.

    try searching. {7} $

  • Find/replace the numbers?

    I like very much all my numbers in small caps, but always manually go through and change them all. Can I find/replace all numbers with a number of small capitals? CS3/Mac

    You can do this by using a GREP.

    1. go in the tab GREP in the FInd\Change dialog box find it what field type in \d

    2. in article Format change click on the empty area and in the dialog box that opens, go to the tab "Basic character Formats" and chose small caps of the case drop down. OK to the dialog box

    3. change all

    You can save this query to other references.

    Thank you

    Javed

  • Find/replace, highlight found text script

    Hello

    I wrote this script and it works fine. But what I want to do is to go through each word found individually (as in the Find/Replace dialog box with the button "find next").

    This is an excerpt:

    app.findTextPreferences = app.changeTextPreferences = null;
    var what = app.findTextPreferences.findWhat = "ensure";

    app.changeTextPreferences.changeTo = "make" sure;
    var found = app.activeDocument.changeText ();
    If {(found.length = 1)
    Alert (found.length + "instance of"ensuring"changed");
    } else {}
    Alert (found.length + "instances of"ensuring"changed");
    }

    I want the script to each instance of "ensure" my active selection that I can see where they are before I change.

    Thank you

    Hi guys,.

    try this one:

    app.findTextPreferences = app.changeTextPreferences = null;
    app.findTextPreferences.findWhat = "ensure";
    app.changeTextPreferences.changeTo = "make sure";
    
    var allFounds = app.activeDocument.findText();
    for (var i = 0; i < allFounds.length; i++) {
      var curFound = allFounds[i];
      curFound.select();
      app.layoutWindows[0].zoomPercentage = app.layoutWindows[0].zoomPercentage;
       if(confirm("Do you wish to change this instance?",undefined, "Find/Replace")) {
         curFound.changeText();
      }
    }
    
    app.findTextPreferences = app.changeTextPreferences = null;
    

    Disadvantage of the confirm dialog box: there is no exit button.

  • GREP find/replace + paragraph Styles

    Hello

    I'm editing a long document and have benefited from the assistance of the community already, but being new GREP Style, find/replace, I need to ask for additional help.

    Below a screenshot of the script (original). Two blocks of text you see anticipated by the icons have have styles of different paragraphs. Icons are placed like custom glyphs.

    Now, the last line with C2, 9, 14,... is the target of this post. They are buses of London and I created a paragraph with another icon. The copy that I work with unfortunately is as you see. Buses will follow «;»

    Resulting to place a \r after the semicolon and assign the new paragraph style. The item to work with is (probably) the last "," before the registration of the bus. All entries have it in the same way, where a search/replace global grep should work fine.

    My attempts:

    I used of a previous debate (? < =------;)) [^ ;] + $ to match everything from the end until the last semicolon, but then I found the problem preserving the matched characters and placing \r (using the (? < =-;). start at the beginning and stops at each point comma + space)

    So question: how to stop at the first semicolon at the end and replace the space with \r to create a new paragraph?

    Then, it is two question :-)

    From my previous attempts, I noticed that when you replace the semicolon + space with \r, and change the style of paragraph at a time (from Rail to Bus) caused the Rail paragraph style change (logic) to the style of Bus. So I tried to say the paragraph style of the track "Following paragraph Style is style of Bus" (and not to change the paragraph style in find/replace), but in a way that no longer works.

    Second question is: given to split the find/replace in two steps, how then transform / apply to newly created paragraph the correct style of Bus?

    Thank you in advance for your valuable assistance. So far, the community has been great!

    Antonio

    Original

    Screen Shot 2016-07-12 at 22.32.23.png

    Result for

    Screen Shot 2016-07-12 at 22.54.51.png

    Hi Antonio,.

    If I understand correctly, in 2 regex [1 click play with Multi/find-replace our friend Martinho da Gloria]:

  • Find whole words with Grep Style

    Hi, need some help with this, he cannot know.

    I need to find some words in the style of a paragraph. I have created a character style to 'be bold' and you want to paraghaph style 'ainesosat' to use it when there are words in the paragraph.

    the words are for example

    Rasvaton maitojauhe

    Maitojauhe

    Juustojauhe

    Kerma

    VOI

    I know I can find these with this string:

    Rasvaton maitojauhe | Maitojauhe | Juustojauhe: Kerma. VOI

    but I don't want to find for example:

    Voimakassuolainen

    -includes "Voi".

    Also the words could begin with capital letter or not. I can of course dublicate chain and do both, with or without capital letters, but if there is a better solution for it, I'd be happy to hear...

    Tero

    1. add parentheses and word limits:

    \b(rasvaton maitojauhe | Maitojauhe | Juustojauhe | Kerma. \B voi)

    2. Add the flag "ignore case" at the beginning:

    (? i) \b(Rasvaton maitojauhe | Maitojauhe | Juustojauhe | Kerma. \B voi)

    See InDesign help | Find/replace for GREP options. You can use almost all the search commands in a GREP style, but does not replace those. ('Almost', because a GREP style, by definition, is limited to a single paragraph to work, and tempting to cross paragraphs automatically him will fail.)

  • Using find/replace to find empty cells in a table

    I'm working on several catalogues pages where we apply styles of our catalogues. The find/replace feature really helped do, but I can't seem to find a way to find an empty cell in a table to add a style to only the cells that are empty. If someone knows a way to do this, saving me a bunch of times and I would be very grateful!

    Hello

    With GREP, this regex can probably help you: (?-m) ^ $

  • find the percent with grep sign

    Hello. I know it must be simple, but I can't seem to find it: how to find the percent with grep sign? Or % or -% nor [%] seem to do.

    Thank you

    There is nothing in particular the % sign: you should be able to find it by using one of the three methods you have tried. Have a good overview of the control panel search/replace. Don't find it what domain contain only the %? No space lurking here? It is on a locked layer? You have a style of paragraph or character set in the Panel "Find format '?

    Peter

  • GREP: How to replace a paragraph with a manual line break break?

    Hello.

    I want to replace a few paragraph breaks (Enter) with manual line breaks (SHIFT + ENTER).

    How do I do that?

    Any help would be appreciated.

    GREP codes for all functions and special characters can be found in the help: help InDesign | Find/replace

    In this case, you do not want to change

    \r

    TO

    \n

    Be aware that this will stick together, paragraphs with all the consequences for its paragraph styles. I rarely do this (and then only unformatted text!) that I don't know yet if it will apply the above the following paragraph paragraph style, or vice versa.

  • I can target fat with GREP - in dialog paragraph styles?

    Hello.

    I have a number of paragraphs which are mainly "regular" (as the font style: ordinary) but they also have a few bold throughout.

    I'm doing a paragraph style that will apply a character style to text bold using GREP.

    Is there a GREP code for this (to not apply the character for the "BOLD" style and nothing else)?

    I know it's easy to do in the Find/Replace dialog box, but I wonder about the paragraph style dialog box in the GREP section.

    Any help would be greatly appreciated.

    Hello

    Indeed, it is easy to do.

    You do not have to use GREP, you can use the query to search/replace text.

    Start by creating your character for "BOLD" style. (Let's call it "CBold")

    Then create your paragraph style, with your desired settings (let's call it "PReg")

    Finally, click on search it icon 'specify attributes to find', 'Bold' and replace it with character styles and paragraph previously defined:

    Who will do the job.

    Please note that this "erases" all text attributes (for example, italic...) in your paragraph.

    Also, it will apply changes to paragraph all if no style is specified in the search for options: including securities i.e.

    So, be careful when you use this method...

  • InDesign CC Grep find/replace to replace the character of space per paragraph (fly)

    Hello InDesigners,

    I'm trying to clean up a 99 page document. In the file, titles of chapters, in capital letters, followed by a space, which is then followed with text more uppercase there. This always occurs at the beginning of a paragraph.

    I'm trying to target the space character that appears just after the number of chapter and Exchange to a number (fly).

    For example:


    CHAPTER 22 SUNDAY UNDERGROUND

    I want the Grep to change this as follows:

    CHAPTER 22

    SUNDAY UNDERGROUND

    I know that to do this job, I need to use positive look behind and positive Look Ahead, at first, I just tried to isolate CHAPTER 22 using the following:

    ^ \u{2,}\s\d+

    It worked. However, as soon as I cut and paste into P.L.B., find/replace says that it does not match.

    (?<=^\u{2,}\s\d+)\s


    The culprit seems to be the comma that comes just after the number 2. If I take, I get a match, but just not the one I wanted.


    Why P.L.B. does not accept the comma as part of the range in my definition grep?


    (FYI, I prefer to use wildcards with a specified scope, rather than literal text).

    It is indeed the comma, and the reason why it does not work because the flavor of InDesign's GREP does not allow a variable length argument in its lookbehinds. And the construction "has {x, y}" indicates a variable length.

    "Chapter" only you know how many characters to uppercase, and even the exact text, you can use

    (?<=^CHAPTER>

    the first chapters to a number, then

    (?<=^CHAPTER>

    for the rest. In your version of InDesign, I guess there is also a possible solution with the fairly new \K "forget - me" operator but I have not yet enough experience with that. It should look like this:

    ^ \u{2,}\s\d+\K\s

    but you will have to experiment a bit to see how to work with the replacement string.

    In addition, you should only use the name of "fly" for a character that looks like this: "¶". The code that you insert will call it a 'return' or 'paragraph return. Initially, I took your question literally, and it sounded as if you were after this result: "CHAPTER 22 ¶ SUNDAY UNDERGROUND"

  • Why I can't get a hit with the find/replace glyphs palette. Faces of fonts checked.

    Screenshot 2015-11-04 00.30.31.png

    I received a copy (word doc) with a table using glyphs Sq Root in place and place check marks. Looking to find replace but GREP and text can't seem to manage the ROOT SQUARE or check MARK glyphs. If the glyphs tab of course right?

    Providing I still exact characters corresponding and no delicate Adobe fonts not anchored object with font substitution, that I can't seem to make a match with the glyph of the SQUARE ROOT.

    No idea why? Attack from a previous thread on my confusion even find these glyphs of fonts that appear to contain them who do not.

    Hey thanks for this tip, I've seen this kind of keyboard shortcuts commands, but never thought to use it in this situation. It turns out that, because the glyph is in a table , I need to set the "Include locked layers and locked objects (FindOnly)" even if the layer is not locked, I suppose that the tables are "locked" per class.

  • GREP code for find/replace

    Hello world

    I have a list of about 500 entries, with each entry formatted as follows:

    First name [tab] [tab] [tab] State level

    I need to do a find/replace using GREP code that will target the tab between the first and last name and replace it with a space. Then I need to target the tab between the name and the State and replace it with a comma and a space. Then finally, I need to focus on the tab between the State and the level and also replace it with a comma and a space.

    I was wondering if someone could tell me what would be the code for this type of operation?

    Appreciate any assistance.

    To find

    ^([^\t])+\t

    Replace

    $1 [space]

    To find

    \t

    Replace

    [space]

  • I'm looking for links Hypertext in find/replace the dialogue (without applying a character style).

    I have 7000 hyperlinks in my document, with different character styles ("italic", "bold" and "italic +"BOLD""). I need to apply the blue color to each of them. If I ask a new character style "hyperlink" to all, I'll lose my formatting.

    Is there a way to find hyperlinks (for themselves, not their format) dialog find/replace in order to create and apply 4 different character styles ('hyperlink_regular', 'hyperlink_bold', 'hyperlink_italic' and ' hyperlink_bold + italic")?

    Sorry for my English, thanks for the help!

    Use Javascript!

    You can use this Javascript, for example. (Instructions on how to use a JavaScript in InDesign can be found elsewhere).

    blue = app.activeDocument.swatches.item("Blue");
    for (a=0; a
    

    Take care to provide the correct color swatch name in the first line.

  • Use Grep to find/replace

    I'm trying to find how to use GREP in find/replace of chage the formatting of a text which is a spreadsheet.

    I worked on the GREP query "~ b (\d\d) ~ b ', which is a paragraph return, followed by two digits, followed by another paragraph of return

    and then it is replaced by ' \t $1 ~ b ', which is a tab, found two numbers and a paratrooper returned.

    What I have to do is change the query to search for ANY number of digits, (which may be delimited by commas: e.g. 23, 36, 48, 50), then replace with a tab + found text.

    I guess what I'm looking for is a way for the query find "any text between two paragraph returns, no matter what that length", but I don't know how to do this. All of the generic options seem to find a single exampler (a figure, a character etc.)

    And you came so far

    Repetition operators are? (zero or one), * (zero or more) and + (one or more times). You can also specify the exact number: {at least up to the}.

    All of these operators are "greedy" by default - they match as much as possible. To to match as less as possible (which I'm sure you will come, sooner or later), add another? After the expression of repeat.

    If this is a number, then possibly another (which will be always included):

    \D\d?

    and what a figure, then zero or as much as 9999999,93856 million:

    \D\d*

    which is functionally identical

    \d+

    And it is between 3 and 8 figures but will be forced to use the shortest possible match:

    \d{3,8}?

    Having said that: a quick & dirty solution for your real problem is to find any amount of numbers, spaces, and comma:

    ~ b [\d,] + ~ b

    (there are more here because otherwise it would correspond also to an empty line). The [..] a list of the hooks - it will match to any unique inside code.

    A more complicated but 'cleaner' way is looking very precisely that for many, comma, space, number sequences - it is cleaner because it lines poorly trained (comma without a space) is fried!

    (She also has another code - operators in parentheses. Look at their place in a good reference GREP - lost people are enthusiastic about Peter Kahrel O'Reilly title, because there on the use of GREP in InDesign.)

    ~b\d+(, \d+)*~b)

Maybe you are looking for

  • Moto g4-Microphone does not work does not correctly

    The problem is that when I am in a call I can hear the other person properly, but my voice does not reach the other person. But when I make the call in speakerphone mode, everything works fine. I think that my microphone is all right when I record vi

  • Printer shows offline?

    I have an Officejet Pro L7680 printer, and I have two new laptops Windows 7 who share the same problem through the wireless home network.  The printer status offline, but when I restart the laptop, it prints documents that are waiting in the print qu

  • HP Office jet Pro 8600: 8600 all-in-one does not print

    First of all, I'm very technically challenged... My printer is connected by radio to two computers. The two are not able to print anything. They have all two printed up to that we have a new computer in and then we worked for a little while and the o

  • A M58 9960-AKU works with an ATI BIZVIEW 2400 graphics card?

    I have a client who needs to run 4 monitors on its new Lenovo M58.  I installed the card, tried everything I can think of to get the M58 to recognize, and when I go to install the ATI drivers for it tells me no ATI device.  I tried to adjust the vide

  • Classes in two files .java talk

    Hello, if you have A class in a separate from your main application class in the main .java file source .java file, you can do something like this: File main .javaClass myapp. {ClassA joe = new ClassA();Joe.doThis ();Public int doThat() {...} in the