Using grep to find one match per line

Hi,
How do you get grep to return a single line even when multiple matches are found on the same line?
I tried the (?-m) and (?-s) without success.
eg. searching for the string "sin" in the following line should return only one result not 2.
SG SIN Singapore
I don't want the search to stop after a single match, it should continue on successive lines
Thanks,
SB

Sure. Let GREP find an entire line at once:<br /><br />>^.*sin.*$<br /><br />But it won't work, I'm afraid. You insist that looking for "sin" <br />i will find <br />a match in "SG SIN Singapore"; and not one but two. It won't. Try it.<br /><br /><pre> __<br />(..)<br /> _\</pre><br />Got that? So use the 'case insensitive' switch<br /><br />>(?i)^.*sin.*$<br /><br />or (perhaps better, in this case), as you seem to search for the three letter codes, use<br /><br />>^.*\<SIN\>.*$

Similar Messages

  • Find/Change Grep only finds one instance per paragraph, where am I going wrong?

    Hi,
    I've been using a Find/Change Grep to find any price with a comma and change that comma to a thin space (Newspaper's editorial style).
    But the Grep only finds the first instance of this per paragraph.
    Sample text...
    "$200,000 $200,000 $200,000.
    text at start of paragraph $200,000
    $200,000 text at end of paragraph
    tab     $200,000."
    In the sample the grep would miss the second and third price on the first line.
    I've been using...
    Find...
    (?<=\$)(\d{3})\,?(\d{3})
    also tried (\$\d{3})\,?(\d{3})
    Change to...
    $1~<$2
    Is there anything I can add to find these last two prices?
    I've been using this in combination with Batch Find Replace script, so different greps are set up for 5,6 and 7 digit numbers that start with $.
    Thanks.

    Try this,
    Find what: (?<=\x{0024})(\d{3})\,?(\d{3})
    Change to: $1~<$2
    Vandy

  • How to use GREP to find one particular word with automatic hyphen?

    I know I have in my text a word with automatic hyphen on the end of line, say Wo-rd.
    How can I find it?
    Thanks.

    I think you might do better to edit the hyphenation in the Dictionary.
    One reason words hyphenate incorrectly is the wrong language has been applied. Both spell checking and hyphenation rules are governed by the language selected for the text, and language is a character-level attribute so that you can select inidvidual words and assign a different language to them if you like.
    If that's the probelm here, you can look for the word using find/change (without worying about the hyphen) and change the language for all instances.
    In either case you will be far better off fixing the problem on a global scale in the document than you will be finding a particular instance of that word at the end of a line. Any editing you do in the future may cause the problem to reappear somewhere else.

  • Using Grep to find/replace

    I'm trying to find out how to use GREP in find/replace to chage the formatting of some text that comes in from a spreadsheet.
    I worked out the GREP query "~b(\d\d)~b", which finds a paragraph return, followed by two digits, followed by another paragraph return
    and then it is replaced by "\t $1~b", which is a tab, the two found digits and a para return.
    What i need to do is to amend the query to find ANY number of digits, (which may be comma delimited: eg 23, 36, 48 ,50), and then replace with a tab + found text.
    I suppose what I'm looking for is a way for the query to find "any text between two paragraph returns, no matter what tthe length", but I don't know how to do this.All the Wildcard options seem to find just one exampler (one digit, one character etc)

    And you came so far
    The operators for repeat are ? (zero or once), * (zero or more) and + (once or more). You can also specify exact numbers: {at least,up to}.
    All of these operators are "greedy" by default -- they will match as much as possible. To match as least as possible (which I'm sure you'll come up against, sooner or later), add another ? after the repeat expression.
    So this will find one digit, then optionally another (which will always be included):
    \d\d?
    and this one digit, then zero or as much as ten million million zillion:
    \d\d*
    which is functionally the same as
    \d+
    And this will find between 3 and 8 digits but will forced to use the shortest possible match:
    \d{3,8}?
    That said: A quick & dirty solution for your actual problem is to find any amount of digits, spaces, and comma's:
    ~b[\d, ]+~b
    (we need the plus here because otherwise it would also match an empty line). The [..] brackets an Inclusive list --- it will match any of the single codes inside.
    A more complicated but 'neater' way is to search very specifically only for number, comma, space, number sequences -- it's neater because that way malformed lines (comma without a space) will be skipped!
    (It also introduces another code -- the parentheses operators. Look them up in a good GREP reference --lost of people are enthousiastic about Peter Kahrel's O'Reilly title, because it's about using GREP in InDesign.)
    ~b\d+(, \d+)*~b

  • SC gets split into one PO per Line even when the vendor is the same.

    Hello,
    If  I create a Shopping cart with multiple lines, it gets split into one PO per Line even when the vendor is the same.
    What can I do to get the split per vendor?
    SRM 4.0
    Regards,
    Shaiek

    Hi,
    Delivery address is also a split criteria
    Kind regards,
    Yann

  • I write a mail and send it but when there is only one word per line. What do I wrong?

    I write many word per line but when I send it will turn to be only one word per line

    Did you check the HTML code of that message to see if tags like "span" or "p" or "div" were added or other CSS code to limit the width?

  • Long thread squeezes later messages onto one word per line

    Hi and thanks in advance.
    I have some really long threads that are readable for the newest messages but the later messages as you scroll down get squeezed so they are almost unreadable; please see the screenshot.
    Any suggestions appreciated.
    Thank you.

    Perhaps the relevant timeouts are socket/network related in this case.
    To detect "silent" network failures, WebLogic uses a heartbeat mechanism, but I'm told that one should not tune the related settings too aggressively. I think this is tunable on a per server basis -- at least for the default network channels. Specifically there's heartbeat interval and period length on the console at "Server -> Configuration Tab --> Tuning Tab --> Advanced".
    There's also "Complete Message Timeout" under "Protocol -> General".
    In addition, TCP/IP timeouts are tunable on the operating system itself. I don't know the specifics for Solaris.
    Tom

  • Using SQL to find a match in consecutive data

    Hi
    I am trying to find a way (within a single SQL statement if possible) that will return a value based on whether a match is found between two points of data.
    Please let me demonstrate:
    create table
    routetest
    as
    select
    1 routeid,
    0000 routeposition,
    null actiontype,
    null activityid
    from dual
    UNION
    select
    1 ,1000, 'Delay', null
    from dual
    UNION
    select
    1 ,1100, 'Activity', 'Letter'
    from dual
    UNION
    select
    1 ,1200, 'Activity', 'SMS'
    from dual
    UNION
    select
    1 ,1300, 'Activity', 'Email'
    from dual
    UNION
    select
    1 ,1400, 'Activity', 'Bar'
    from dual
    UNION
    select
    1 ,1500, 'Delay', null
    from dual
    UNION
    select
    1 ,1600, 'Activity', 'SMS'
    from dual
    UNION
    select
    1 ,1700, 'Delay', null
    from dual
    UNION
    select
    1 ,1800, 'Activity', 'Letter'
    from dual
    UNION
    select
    1 ,1900, 'Activity', 'SMS'
    from dual
    UNION
    select
    1 ,2000, null, null
    from dual;
    select * from routetest order by 1,2
    ROUTEID ROUTEPOSITION ACTIONTYPE ACTIVITYID
          1             0                     
          1          1000 Delay               
          1          1100 Activity   Letter   
          1          1200 Activity   SMS      
          1          1300 Activity   Email    
          1          1400 Activity   Bar      
          1          1500 Delay               
          1          1600 Activity   SMS      
          1          1700 Delay               
          1          1800 Activity   Letter   
          1          1900 Activity   SMS      
          1          2000                     
    12 rows selectedReturn a value where, for startpos X does activity Y exist between X and last activity before non-activity/end.
    Return
    0 for no - it does not,
    1 for yes, at the current position and
    2 for yes, after the current position (but before before the next non-activity)
    Expected results:
    Startpos=0
    Activity=Letter
    Returns: 0
    Startpos=1000
    Activity=Letter
    Returns: 2
    Startpos=1100
    Activity=Letter
    Returns: 1
    Startpos=1000
    Activity=Bar
    Returns: 2
    Startpos=1100
    Activity=Bar
    Returns: 2
    Startpos=1400
    Activity=Bar
    Returns: 1
    Startpos=1400
    Activity=Bar
    Returns: 1
    Startpos=1500
    Activity=Letter
    Returns: 0
    Startpos=1600
    Activity=Letter
    Returns: 0
    Startpos=1700
    Activity=Letter
    Returns: 2
    Does that make any sense?
    Thanks
    Martin

    Hi, Martin,
    Thanks for posting the sample data so clearly. Could you post the results you want from that data just as clearly?
    I'm fairly sure you want to compute something like grp_num in the query below, so you can tell that (for example) routepostition 1000 is in the same group as 1100, but not 1600.
    I'm less sure what you want beyoned that. Also, I'm just guessing at what role routeid plays in this problem.
    WITH     got_grp_num     AS
         SELECT     routetest.*
         ,     ROW_NUMBER ()      OVER ( PARTITION BY  routeid
                                  ORDER BY     routeposition
               - COUNT (activityid) OVER ( PARTITION BY  routeid
                                  ORDER BY     routeposition
                                )     AS grp_num
         FROM     routetest
    SELECT       routeid, routeposition, actiontype, activityid
    ,       CASE
              WHEN  activityid   IS NULL     THEN  0
              WHEN  activityid   = 'Letter'     THEN  1
              WHEN  1 <= SUM ( CASE
                             WHEN  activityid = 'Letter'
                             THEN  1
                             END
                          ) OVER ( PARTITION BY  routeid
                                ,           grp_num
                                 )          THEN 2
                                  ELSE 0
           END     AS letter_code
    FROM       got_grp_num
    ORDER BY  routeid, routeposition
    ;The query above produces these results:
       ROUTEID ROUTEPOSITION ACTIONTY ACTIVI LETTER_CODE
             1             0                           0
             1          1000 Delay                     0
             1          1100 Activity Letter           1
             1          1200 Activity SMS              2
             1          1300 Activity Email            2
             1          1400 Activity Bar              2
             1          1500 Delay                     0
             1          1600 Activity SMS              0
             1          1700 Delay                     0
             1          1800 Activity Letter           1
             1          1900 Activity SMS              2
             1          2000                           0I know that's not exactly what you want, but I hope it gives you some ideas.

  • 3 way match between PO/GR/IR per line item

    Hi..
    I'm having an issue with 3 way match between PO/GR/IR. I want to this on line item level. As standard, SAP will compare line items based on line item numbers when doing the match (at least for quantity match). However, this is not possible since the vendors don't always use the line items in the PO (send to them) to create the invoice. And sometimes they simply leave out the line item number. However, the material number is always on the PO, GR and IR. Is it possible to do the 3 way match per line item using the material number as the unique identifier?
    Kind regards
    hundvov

    hi
    Three Way Match
    Yes, Three Way Match Means PO -> GR -> IV
    For this, You need to Put Tick mark against GR Based IR in Purchase Order Item Detail Invoice Tab and Vendor Master Purchasing Tab.
    Once This Purchase Order is Saved. You cannot do / System will not allow you IR Until you make Goods Receipt for the Purchase Order.
    The same applies to External Services.
    http://sap.ittoolbox.com/groups/technical-functional/sap-log-mm/sap-3-way-match-configuration-1639406
    http://sap.ittoolbox.com/groups/technical-functional/sap-log-mm/3-way-invoice-match-1381773
    regrds
    kunal

  • Compact output of pacman -Qi(e) showing only prog,desc,size 1 per line

    /* ================================================================================================
    REVISED May 14, 2009
    REWRITTEN - to check for buffer overuns
    Dumb utility which takes the output of pacman -Qi(e) and creates a tab delineated text file
    showing the program name, description and file size, one program per line to be read
    with a text editor or spreadsheet.
    compiling -> q++ qi.cpp -o qi
    Program can be run either as:
    qi // which creates:
    pacQi.txt // output of pacman -Qi > pacQi.txt
    pacQi.xls // tab delineated text file of all installed programs.
    or
    pacman -Qie > somefile
    qi somefile // which creates
    somefile.xls // A tab delineated text file of explicitly installed programs
    ==================================================================================================== */
    #include <iostream>
    #include <fstream>
    #include <stdlib.h>
    #include <cstring>
    #include <string>
    using namespace std;
    string formatstr(const string ="", char=' ' , int prec=0, int strlength=0 );
    int findString ( string, string );
    string padString ( string, int,char = ' ') ;
    const int progWidth = 25 ;
    const int descWidth = 60 ;
    const int sizeWidth = 25 ;
    const int cstring_buffer = 100;
    int main(int argc , char * argv[])
    char ch ;
    unsigned int findPos=0, start, len ;
    char sourceFileName[cstring_buffer];
    char targetFileName[cstring_buffer];
    string strLine;
    string progName, progDesc, progSize;
    if (argc == 1 ) // no arguments provided creates pacQi.txt
    strncpy(sourceFileName,"pacQi.txt", 12);
    strncpy (targetFileName, "pacQi.xls",12 );
    system ("pacman -Qi > pacQi.txt");
    else // user supplied name
    len = strlen(argv[1] ) + 6 ;
    if (len > cstring_buffer )
    cout << "\n\nProgram Exiting to Prevent Buffer Overrun\n\n";
    exit (0);
    //cout << endl << argv[1]<< " length is : " << strlen(argv[1]) << endl; // testing
    strncpy (sourceFileName,argv[1], strlen(argv[1]) + 2 ) ;
    strncpy (targetFileName,argv[1], cstring_buffer - 10 ) ;
    strncat (targetFileName,".xls",5);
    ifstream ifile (sourceFileName) ;
    ofstream ofile (targetFileName) ;
    progName ="";
    progDesc = "";
    progSize = "";
    while (ifile.good() )
    getline(ifile,strLine);
    findPos = findString ("Name", strLine); // Find Name Line
    if (findPos > 0 )
    for (start=findPos+2; start < strLine.size();start++)
    ch = strLine[start];
    progName = progName + ch;
    progName = padString(progName,progWidth);
    progDesc=""; // remove remants of progDesc second line
    progSize="";
    findPos = findString ("Size", strLine); // Find Size
    if (findPos > 0 )
    for (start=findPos+2; start < strLine.size();start++) // kill trailing K
    ch = strLine[start];
    if ( ( (ch >= '0') and (ch <= '9') )or (ch == '.') )
    progSize = progSize + ch;
    string temp;
    temp ="";
    progSize = formatstr(progSize, ' ' , 3, 25);
    findPos = findString ("Description", strLine); // Find Description
    if (findPos > 0 )
    for (start=findPos+2; start < strLine.size();start++)
    ch = strLine[start];
    progDesc = progDesc + ch;
    progDesc=padString(progDesc,descWidth);
    if (progName>"" and progDesc>"" and progSize>"")
    ofile << progName << '\t' << progDesc << '\t' << progSize <<endl ; // Print program record
    progName ="";
    progDesc = "";
    progSize = "";
    } // while loop
    ifile.close();
    ofile.close();
    } // E N D M A I N
    //==================================================================================
    int findString ( string source, string target) // if source found returns ":" + 2
    int found;
    string test;
    test = source;
    found = target.find(source);
    if (!found )
    found = target.find(":");
    if (found < 0 )
    found =0;
    return found;
    //========================================================================
    string padString ( string str, int num, char ch)
    string temp;
    int len;
    temp = str;
    len = str.size();
    for (int start = len; start < num; start++)
    temp += ch;
    return temp;
    //===========================================================================
    string formatstr(const string str, char leadchar, int prec, int strlength)
    using namespace std;
    int i1,i2,len;
    int sptr,tptr,wholeDigits=0,fracDigits=0;
    int fracPtr=0;
    int noc,commaptr; //Number Of Comma's
    bool hasDec=false, isNeg =false;
    string temp,temp2,fracStr,wholeStr,s;
    s=str;
    len=s.size(); // Length of String w/o '-' sign
    temp="";
    if (str[0]=='-')
    isNeg=true; // If negative kill minus sign
    for (int i1=1;i1< len ; i1++ ) // Copy rest of string to s
    temp=temp + str[i1];
    s = temp;
    len=s.size();
    for (sptr=0;sptr <len;sptr++) //Find # of digits wholeDigits + in decimal
    if (s[sptr]!='.')
    wholeDigits++;
    else
    fracPtr=sptr;
    hasDec=true;
    wholeDigits=sptr ; // Represents digits before dec since sptr is at dec. don't increment
    fracDigits = (len-(fracPtr)); // Back into # of decimal digits
    break;
    fracStr="";
    if (hasDec)
    for (i1=fracPtr;i1<len;i1++) // Build fracStr
    fracStr=fracStr + s[i1];
    temp = ""; // bugaboo caused by negativity
    for (sptr=wholeDigits-1,tptr=0; sptr>=0 ;sptr--,tptr++ ) //Reverse wholeDigitsing w/o decimal
    temp= temp + s[sptr];
    temp2=""; // commatize reversed string to temp2
    commaptr=0;
    noc = temp.size() / 3 ; // S E E IF W O R K S
    for (sptr=0;sptr<wholeDigits;sptr++)
    if (commaptr==3 && noc)
    temp2=temp2 + ',';
    noc--;
    commaptr=0;
    temp2=temp2 + temp[sptr];
    commaptr++;
    temp=""; // Reverse commatized Reversed String (wtf)
    for (sptr=temp2.size() -1 ; sptr >= 0 ; sptr--)
    temp = temp + temp2[sptr];
    s=temp;
    len =fracStr.size();
    if (prec < 0)
    ; // Put string back
    if (prec == 0 ) // Leave out fractional part
    fracStr="";
    if (prec > 0 )
    temp="";
    if (fracDigits > prec) // Will Truncate decimal not round up
    for (int i1=0;i1<=prec;i1++)
    temp=temp + fracStr[i1] ;
    fracStr=temp;
    if (fracDigits < prec +1 && len >0) //fractDigits include '.'
    for (int i1=1;i1< (prec-len+2);i1++)
    fracStr=fracStr + '0';
    if(len==0)
    fracStr='.';
    for (int i1=1; i1 <= prec; i1++)
    fracStr = fracStr + '0';
    s=s+fracStr;
    temp = " " ;
    temp[0]=leadchar;
    temp= temp + s;
    if (isNeg)
    temp = '(' + temp + ')';
    i1=temp.size();
    temp2="";
    if (strlength > 0 ) // Pad String for strlength
    i2=strlength -i1;
    for (i1=0;i1<i2;i1++)
    temp2=temp2+' ';
    temp = temp2 + temp;
    s = temp;
    return s;
    Last edited by ljshap (2009-05-14 16:53:51)

    Daenyth wrote:If you're using C, why not either use libalpm instead of system(pacman...), or add the functionality to pacman itself (-Qqi)?
    I never heard of libalpm, but I'll look into for my own information.
    If I added the functionality to pacman itself (assuming i knew how), I would have to change the source and recompile every time there was an update.  My program should work with new versions unless there is a major change to the output of pacman -Qi(e).
    My "program" produces the following output format:
    52dec                              liba52 is a free library for decoding ATSC A/52 streams.                          207.860
    aalib                                AAlib is a portable ASCII art GFX library                                                           824.000
    abiword                           A fully-featured word processor                                                                 12,833.000
    abiword-plugins            Various plugins for Abiword                                                                           4,199.000
      It can be read with a regular text editor or a spreadsheet where it can be sorted by size if you want to see whats taking up hardrive space without scrolling through the detailed output of pacman -Qi.
    Obviously, the program has extremely limited usefullness unless you just want to to see installed programs, it description and size in a more compact format either out of curiousity or your planning on reinstalling but want to see the descrition as well as the program name.
    I appologize if this functionality is already available in libalpm or elsewhere, but I figured I'd put it up in case anyone wanted it.
    Thanks for the additional information.

  • Using Grep on multiline textframe

    Hello
    I am using GREP to find text and replace in scripting it but It seems to not work on multiline text. Ex.:
    My texte
    My text2
    I use ^.({8})(My text2){1}) to replace the 'My text2' but it doesnt work. Is there any way to make safe text subtituions with grep?

    If you have a return between the two lines, the GREP needs to take that into account... (i.e. \r)
    Harbs

  • T61 trashes Eye-one Match display profiles on reboot

    Loving my new t61 and even getting used to Vista! But the setup does two annoying things on reboot:
    1) It resets my default browser page to the lenovo live page (I will figure this one out, I know)
    2) But worse, it either removes or corrupts the monitor profile i paintakingly create using Gretag Macbeth Eye-one match. (this one has me bafled)
    Any advice?
    Jack

    After talking with the guys over at X-Rite, and listening to advice from people like William, I went with 6500 (D65) for the white point. The exception to this is laptop LCD displays. For those, they recommend using Native white point.
    For gamma 2.2 is the unquestioned setting. It's what PCs use, and if you use 1.8 your images are going to be too dark for 90% of the displays out there. If your images will never be viewed on another display, and you'll only be printing them yourself, and you really prefer 1.8, you can use it instead, but in most cases you'll want 2.2.
    Luminance is a bit trickier since it depends on the brightness of your work area. (Yes, we're referring to turning down the brightness with the "sun" buttons on your keyboard.) If you're in a bright office and you can't reduce the brightness (an office building for example), then the recommended setting of 120 may be too dark. You basically want the brightness of the office slightly lower than the display. If you can do it install low watt 5000k bulbs (easy to find online). This will give you the best white light in your work space. Get the lighting as dim as possible, then try turning the display down to the recommended setting (you'll need to measure it using the advanced mode with the Eye-One). If 120 works in your area, that's great. If it just seems slightly too dark, give it a couple of days and you'll adjust. Ultimately, even though I changed my bulbs to 5000k, my office is too bright for 120. I ended up using a custom setting of 200 and which puts my display brightness around half way.
    So, to sum up, I'm at 6500, 2.2, 200. Ideal, if your work environment can be made dim enough, is 6500, 2.2, 120. Hope that helps!
    Message was edited by: KBeat

  • Assets per line item

    Hi All,
    In SRM 4.0 we are able to create any no of assets for a particular line item. In SRM 7.0, i am able to create only one asset per line item in the SC as the standard code is making the quantity field get defaulted to one only.
    If i change it in debugging, i am able to create any no of assets but i am not able to see all the created assets on the screen only the first asset is getting displayed .... do any one have any idea????

    Hi Lokesh,
    I've tested this in our system with Cost Center assignement, splitting cost center assignment over two cost centers. This didn't work also, probably the exact same behaviour as with your Asset situation.
    Good news: This isn't your fault my SRM 7.0 SP05 system is having the same issues you're talking about.
    Bad news: SAP Customer Message or maybe an OSS Note is available on this, but i doubt it, i've already seen a lot of notes but havn't seen any covering this.
    Found 1 note you could take a look at: Note 1417829 - Multiple account assignment shopping carts end up in error. This note does not cover my extended-classic system situation though, i'll check this one out again when we upgraded SP's: No hurry on this one for me.
    Kind regards,
    Tim

  • Ignore Line break in find text using grep

    Hi everyone!
    I need to find the text in document using grep.
    find text for :
    Xereptatiuria que alique volo eium qui dolupid ut
    voluptatiam earum saestorepel iuscit im quas et modisimodit.
    The above sentence cannot having line breaks. But document having multiple line breaks.
    so, please to give a tip to find the text using grep.
    I am not excepting this type of result by following.
    Xereptatiuriaque\n alique volo\neium qui dolupid ut\r voluptatiam earum\n saestorepel iuscit im quas et\n modisimodit.  ------------this is not.
    Any another way to find (i.e)., ignore the line break
    simply like this, 
    (?s:Xereptatiuria que alique volo eium qui dolupid ut
    voluptatiam earum saestorepel iuscit im quas et modisimodit.)      --------- the line break wherever it is found,ignore line break in single command.
    Thanks by,
    John Peter.

    johnp45247251,
    what do you really want to do?
    Like pkahrel in your other thread Find Grep And Ignore the line break said:
    pkahrel schrieb:
    You're a moving target: you change your question in each post. Do yourself a favour and go and read up on GREP.
    johnp45247251, one question:
    Could it be possible, that you doesn't understand correctly, how Grep really works?
    <edit by pixxxel schubser>
    Furthermore your example text is different to your screenshot. Your text is:
    »Xereptatiuriaque\n alique volo\neium qui dolupid ut\r voluptatiam earum\n saestorepel iuscit im quas et\n modisimodit.«
    And your screenshot shows:
    »Xereptatiuriaque\n alique volo\n eium qui dolupid ut \rvoluptatiam earum\n saestorepel iuscit im quas et\n modisimodit.«
    Normally the text should look like this:
    »Xereptatiuriaque\nalique volo\neium qui dolupid ut\rvoluptatiam earum\nsaestorepel iuscit im quas et\nmodisimodit.«
    Please explain what do you really want to do and exactly if additional spaces are exists or not!
    Could it be:
    you have a text with paragraphs and with many line breaks in that paragraph and there are no spaces exists before or after your line breaks. And is your destination to remove all the line breaks from your text?
    </edit by pixxxel schubser>
    Then the way is not to find the text completly and to ignore the line breaks – the way is to find the line breaks and replace with a space, e.g. like that:
    find:
    \n
    replace with:
    \s
    (change all)
    Regards
    pixxxel schubser

  • Finished script: Use grep find/change to fill in a supplied table of contents

    This script is now complete, and has been the subject of most of my previous posts. Just in case anyone wanted to know what the finished script ended as, here it is.
    Thanks so much to all. A lot of really helpful folks on this board are very responsible for the success of this task. This script is to be one of hopefully many in the creation of our records. But it's a huge leap forward. Thanks again to everyone that helped.
    Cheers,
    ~Nate
    Task:
    Automatically find town names in listings, and fill in table of contents template on page 2 accordingly.
    Example of page 2 toc, initially:
    Example of a page of content. The town names are what need to be referenced on the TOC:
    Example of page 2 toc once script is finished:
    Because of the need to include the transaction dates on the TOC (comes as a provided, tagged-text file), a simple Indesign-generated TOC can't be used alone.
    This script uses an Indesign-generated TOC that's on a master page called "T-tocGen" ... It then uses grep search and replaces to grab the needed information, and insert it into the page 2 TOC.
    The script will update a generated TOC and then search for an instance of a page number, and town name. The generated toc lists all included towns in the following format:
    (line start)## tab townName(line end)
    In Grep, this would be (please note, extra \ for \d and \t ... javascript needs that for some reason):
    ^\\d+\\t(.*)$
    After the script gets the info it needs from a found instance of the above, it replaces that line with "---", to prevent that line from being picked up once again.
    The script with then place the needed page number in it's rightful place on page 2, replacing the XX.
    A while loop is used to repeat the above process until there are no longer any instances of "^\\d+\\t(.*)$" present.
    Not every town runs every issue, so once the script is done, it removes all remaining instance of "XX" on the page 2 TOC.
    FINAL CODE:
    TOC replace
    This script will use grep find/change methods to apply page numbers in
    tocGen to the XX's on page2TOC.
    // define the text frame of generated TOC
        var tocGenFrame  = document.masterSpreads.item("T-tocGen").pages.item(0).textFrames.item(0);
    // udpate generated TOC ... store contents in tocGenStuff
        var tocGenStuff = updateTOCGen();
    // set variable for while loop
    var okGo = "1";
    // while okGo isn't 0
    while(okGo.length!=0)
    // get town info from tocGen
    getCurrentTown();
    // replace XX's with tocGen info
    replaceTown();
    // grep find ... any remaining towns with page numbers in tocGen?
    app.findGrepPreferences = app.changeGrepPreferences = null;
    app.findGrepPreferences.findWhat = "^\\d+\\t(.*)$";
    // set current value of okGo ... with any instances of above grep find in tocGen
    okGo = tocGenFrame.findGrep();   
    // grep find/change all leftover XXs in page2TOC
    app.findGrepPreferences = app.changeGrepPreferences = null;       
    app.findGrepPreferences.findWhat = "^XX\\t";
    app.changeGrepPreferences.changeTo = "\\t";
    app.activeDocument.changeGrep();  
    // clear grep prefs
    app.findGrepPreferences = app.changeGrepPreferences = null;
    //  functions                  //
    function getCurrentTown()
    // grep options   
    app.findChangeGrepOptions.includeLockedLayersForFind = true;
    app.findChangeGrepOptions.includeLockedStoriesForFind = true;
    app.findChangeGrepOptions.includeHiddenLayers = true;
    app.findChangeGrepOptions.includeMasterPages = true;
    app.findChangeGrepOptions.includeFootnotes = true;
    // grep find:  startLine anyDigits tab anyCharacters endLine
          app.findGrepPreferences = app.changeGrepPreferences = null;
          app.findGrepPreferences.findWhat = "^\\d+\\t(.*)$";
    // get grep find results      
    currentGen = tocGenFrame.findGrep();  
    // store grep results content into currentLine
    currentLine = currentGen[0].contents;
    // match to get array of grep found items
    currentMatch = currentGen[0].contents.match("^\\d+\\t(.*)$");
    // second found item is town name, store as currentTown
    currentTown = currentMatch[1];
    // change current line to --- now that data has been grabbed
    // this is because loop will continue as long as the above grep find yields a result
           app.findGrepPreferences.findWhat = "^\\d+\\t"+currentTown+"$";
                  app.changeGrepPreferences.changeTo = "---";
                tocGenFrame.changeGrep(); 
    function replaceTown()
    app.findChangeGrepOptions.includeLockedLayersForFind = true;
    app.findChangeGrepOptions.includeLockedStoriesForFind = true;
    app.findChangeGrepOptions.includeHiddenLayers = true;
    app.findChangeGrepOptions.includeMasterPages = true;
    app.findChangeGrepOptions.includeFootnotes = true;
    // find: XX currentTown .... replace with: currentLine
        app.findGrepPreferences = app.changeGrepPreferences = null;
        app.findGrepPreferences.findWhat = "^XX\\t"+currentTown+" \\(";
        app.changeGrepPreferences.changeTo = currentLine+" \(";
    app.activeDocument.changeGrep();   
    function updateTOCGen()
    //set vars ... toc text frame, toc master pag
        var tocGen  = document.masterSpreads.item("T-tocGen").pages.item(0).textFrames.item(0);
        var tocGenPage  = document.masterSpreads.item("T-tocGen").pages.item(0);
    //SELECT the text frame generatedTOC on the master TOC
        tocGen.select();
    //Update Table of Contents by script menu action:
        app.scriptMenuActions.itemByID(71442).invoke();
    //Deselect selection of text frame holding your TOC:
        app.select(null);
    //store contents of toc text frame in variable
        var tocGenText = tocGen.contents;
    //return contents of tocGen
        return tocGenText;

    Thanks for the reply.
    You are correct but the problem is there are three rows, One row is 100% black, the second is 60% black and the third is 40% black. I want to change the black to blue, the 60% black to an orange and the 40% black to a light shaded blue. In the find/change option you can select the tint you want to find and replace but yea.. does work on table cells.. oddly enough.

Maybe you are looking for

  • Can I Move apps from my acc to new one

    I have an ipad 1 and have just won a new ipad.  I was going to give my old ipad to my daughter but wondered if I can transfer her apps, movies, books etc to another account so that she cannot read, delete, move any of my stuff that may download to th

  • Extracting files out a PDF portfolio

    This is my situation: I made a portfolio with several documents, including PDFs, DOCs and CHMs. Everything works the way it supposed to for PDFs and DOCs, I can read them and extract them, but not with the CHMs. I can't neither view or extract them,

  • Photos from photo booth being saved with weird titles?

    On my imac, when you save a photo from photobooth, its named the same as it was in photo both (such as Photo 1189.jpg) But on my macbook, when i save photos they save as Photo on 2010-10-13 at 15.54 #3.jpg Is there any way to change how they are save

  • Will my mac pro support 10 Optical drives?

    I have a mid 2010 Mac Pro that currently has two Optical drives installed. I believe its the Two 2.4GHz Quad-Core Intel Xeon E5620 "Westmere" processors. I installed a Samaung 840 Evo for the operating system and I have a 6 TB raid installed with 16g

  • Sqlplus process count in Unix

    I need to process 50 sqlplus scripts. At any point of time, the number of scripts running shouldn't exceed 6. If any one of the scripts completes successfully then another one needs to kick off, till all scripts are processed. How do I do this? I tri