Perform grep search

Hi folks,
I was wondering whether it was possible to find and replace using grep. I have the find and replace thing sorted, but I need it to be flexible enough to select any number and alter the value by a set amount. I have done this in InDesign but have become stuck with Illustrator.
I have tried to use an adapted version of the search script from this thread: (CarlosCanto)
var multiplier = parseFloat(2.5);
var search_string = /[-]*[0-9][0-9,.]*\\b/gi;
var replace_string = search_string * multiplier;
var text_frames = active_doc.textFrames;
if (text_frames.length > 0) {
    for (var i = 0 ; i < text_frames.length; i++) {
        var this_text_frame = text_frames[i];
        var new_string = this_text_frame.contents.replace(search_string, replace_string);
        if (new_string != this_text_frame.contents) {
            this_text_frame.contents = new_string;
This simply returns 'undefined'
Do I need to invoke a grep function to parse the pattern through?
Any help would be wonderful.
Thanks

This is what I meant by using UnitValues…
#target illustrator
var idoc = app.activeDocument;
var ilayer = idoc.layers['measurements'];
var oldUnit = prompt ( 'Enter old unit string:', 'inch', 'Convert Units' );
var newUnit = prompt ( 'Enter new unit string:', 'mm', 'Convert Units' );
for ( var i = 0; i < ilayer.textFrames.length; i++ ) {
     var itext = ilayer.textFrames[i].contents;
     var mValue = new UnitValue( Number( itext ),oldUnit );
     ilayer.textFrames[i].contents = mValue.as( newUnit );
If you were to look up the strings table you will see yards, miles, meters, kilometers etc… Plus all the usual stuff just a little less math for you to input… Personally I would still use a dialog with 2 drop down lists for old & new units… That should be simple enough to do…

Similar Messages

  • I perform a search, get results, find the message I was after. How do I locate this message within my (relatively) complex folder and subfolder structure?

    Hi,
    I use structured subfolder system to keep my emails organized (hundreds and hundreds of folders).
    When I perform a search, get a list of results and within this list I find the email I was after, HOW do I locate the message? In other words, how can I open the folder which contains that particular email?
    Thank you in advance for your time and effort.

    Not a perfect solution but maybe a workaround.
    http://www.ehow.com/how_8222645_folder-thunderbird.html

  • How can i perform a search on my external hard drive on my mac pro os x 10.9.2 ?

    how can i perform a search on my external hard drive on my mac pro os x 10.9.2 ?

    Mac OS X 10.9.2 is 12 years newer than 9.2.x.    You need to make sure that Spotlight has indexed the external hard drive by adding it and removing it from Apple menu -> System Preferences -> Spotlight -> Privacy.   Check the menu for it:
    to determine if indexing is still going on, as it will say indexing.
    Alternatively, you can use a non-Spotlight tool, such as:
    http://apps.tempel.org/FindAnyFile/
    http://www.devontechnologies.com/products/freeware/ - EasyFind
    http://www.osxbytes.com/ - iFileX (note the MacUpdate link provided on osxbytes page has a Malware advertisement for MacKeeper, do not download).
    http://www.barebones.com/ Textwrangler has a Search file for content, which works on any Text file.

  • The google feeling lucky app from the address bar is not working, a program called vshare performs a search instead and I am unable to restore the original function. please help

    I do not know how but vshare, has been performing a search everytime I type something in the address bar that is not a complete website i.e. facebook instead of facebook.com
    this is very annoying and I am unable to uninstall vshare, I have even tried uninstalling firefox and reinstalling it

    I had this problem too, and just fixed it, and found a great website that helped.
    1. In Firefox type about:config in the address bar and press ENTER.
    2. Locate and double-click the entry for keyword.URL
    3. Set the value based on which search provider you would like to use for your address bar searches. Here are a few search strings you can use.
    Yahoo: http://search.yahoo.com/search?p=
    Ask: http://www.ask.com/web?q=
    Google: http://www.google.com/search?&q=
    ChaCha: http://search.chacha.com/search/query?searchwithguide=0&query=
    source: http://www.technipages.com/firefox-change-address-bar-search-provider.html
    And if you want the I'm Feeling Lucky search, instead of just the Google page search, then put:
    http://www.google.com/search?ie=UTF-8&oe=UTF-8&sourceid=navclient&gfns=1&q=
    instead of: http://www.google.com/search?&q=
    I just did that, and it worked for me. I had to go through a bunch of the different options, but I found one that worked.
    Source: http://www.google.com/support/forum/p/Chrome/thread?tid=25cf5ea2bc5a2744&hl=en

  • Excluding a character from "Change to" box that is in "Find what" box in GREP search

    Hello all! I am a first time poster but have been lurking around the forums for a few months. I'm trying to produce an InDesign document for a book I'm putting out, and there is a section where I have the following text:
    |  TAB  |1.|  TAB  |Lorem ipsum dolor etc.
    The text doesn't literally say tab, I jsut wanted to highlight that there is a tab of white-space on either side of the number for the line. This occurs numerous times in numerous chapters in the endnotes section. I want to remove the tabs so that the result is:
    1. Lorem ipsum dolor etc
    2. Lorem ipsum dolor etc
    3. etc etc
    I have identified that the way to find these sections is to use the GREP search function with \t\d+.\t. The + is there because the numbers go into the double digits in most chapters for the references. However, I do not want to remove the numbers, just the tabs. Is there any way to add an exclude feature to the "Change to" window of the search function? I've tried just leaving it as \d., but that literally changes the text to
    \d. Lorem ipsum dolor etc
    That's not good. I'm trying to avoid having to do all of this by hand, and of course by the time I get a resolution I'll probably have been better off doing it manually, but I'm looking toward the future and trying to ascertain the best way of streamlining such a process short of not having that kind of format in the first place when receiving the file from my employer
    Many thanks for your advice,
    David

    Peter,
       Just to affirm your assistance, this worked for me. I still don't understand the advanced search features perfectly, but I got the formatting fixed without having to sift through it manually. I found that replacing with "$2. " (minus the quotes) worked well. However, I noticed that searching for (\d). would turn up a digit followed by ANY kind of punctuation, not just a period. I assume therefore that . must mean something different in GREP than I'm thinking it does. I just wanted to find any digit before a full-stop. At any rate, that is something I can find a table of GREP search terms for. I didn't understand the $2 thing until I monkeyed with it. I'm typing now for future generations of newbies that might stumble upon my post. The $2 ignores the second character in your "Find what" field. So for example, if instead you had two tabs then a digit then a tab, you could search:
    Find what: (^\t)(\t)(\d)(\t)
    Change to: $3.
    This would take any occurrence of two tabs, a number, and a tab and replace with a period, ignoring and therefore not changing at all the number. The $3 is saying "ignore the third search term", in this case, the \d.
    A better approach would be to use +. This means "any time you see one or more occurrences of the searched-for character". This would look something like:
    Find what: (^\t+)(\d+)(\t+)
    Change to: $2.
    Here you are saying "Any time you see one or more tabs followed by one or more numbers and then followed by one or more tabs, ignore the digit, delete the tabs before and after, and add a full stop after the number. This is a very powerful search feature, once you understand what you're doing anyway. Hope that is helpful to someone at some point.

  • Can't perform wildcard searches

    Hello world,
    We're using Portal 3.0.9.8.1 with Patch 1949492 installed. This is on 8.1.7.2.4 SE Database.
    When performing a search, cannot include wildcards. E.g. a search for 'test' returns only the exact word 'test'. It does not return 'testing','tester','test1','detests'.
    This is against what Portal's Own Help file states. Click 'Search Tips' on the 'Advanced Search Page' and you are told the following:
    The % character is interpreted literally, so do not include it as a wildcard. If you enter 100% as your search term, search finds content that contains the text 100%, not 1000 or 10000. Wildcards are automatically added to the beginning and end of your search term, so searching for 100 will automatically return content that contains 1000 and 10000.
    If interMedia is installed and enabled, search automatically uses the stem operator to search for words that have the same linguistic root as the specified word. For example, if you specified the word lift, the search feature will return content that contains the words lift, lifting, lifted, etc.
    Both of these statements are blatantly untrue as it does neither.
    Any thoughts Oracle? Has anyone else managed a wildcard search?
    Frustrated
    Dave

    I've just verified in 3.0.9 and wildcards are applied as specified in the documentation, when Text is not enabled. If your search term is 'test' then the SQL query will have the search term %test%. Literal % signs in your search term are escaped, so that if your search term was test% then the query would be for %test^%% escape ^.
    There are a few things to remember. When searching WITHOUT Intermedia Text enabled the search will only match terms in the title and description of the item.
    When, Intermedia Text is enabled, all of the content will be searched. However, as indicated in the documentation, the stem operator will be used. So if you search for 'test' the query is now a Text contains('$test') type query. The default operator is the '$' stem operator, which match terms that have the same linguistic root. So if your search term is 'test' it should match 'tests' or 'testing' or 'tested'. However, it will not match 'test1'. Please refer to the Intermedia Text documenation for more information on the stem operator and Text searching in general.

  • Using footnote markers in a GREP search

    In a 300 page document, with hundreds of footnotes, I want to insert thin spaces between single endquotes and footnote markers. The easiest way seemed a GREP search and repace. I search for (\’)(~F) and replace it with $1~<$2. The result is ’ ’ (endquote-thin space-endquote). When I try to replace AB to A-thin space-B in the same way, the result is right. So what's going wrong? (I also tried ~] for the endquote.)
    (By the way, I have a workarround, but I'd like to understand how GREP searches work.)

    Footnotes aren't really a part of the semi-official GREP definitions, and I imagine the Adobe programmers had to fix a couple of workarounds to make them work at all. They are not simply single characters (quotes, spaces, and possibly text variables are) but "contain" lots of other information, just like anchored objects do. That could be the reason they don't Play Nice with regular GREP operations.
    In this particular case, you can work around it searcing for but not replacing the footnote marker code. Look for
    (\')(?=~F)
    and replace with
    $1~<
    The combo (?=~F) will find but not include the footnote code, and thus nicely circumvent the problem.

  • Script or GREP search line for missing quotation marks (opening or closing)

    Hi there,
    I've being trying to figure out a GREP search that will help me find quotations that haven't been opened or closed properly. Does anyone know if there exists a script that will mark/help me find the quotation marks that incorrectly stand alone? A GREP search line would be fine too.
    Following is an example - just to make sure I made myself clear:
    'why is the closing quotation mark missing after the question mark? I asked.
    'I don't know, this line seems to be fine, with opening and closing quotation mark,' I answered.
    Although this line is missing an opening quotation mark.'
    Hope somebody can help me, I'm pretty sure I'm not the first person searching for a solution on this issue - sorry, I'm not to bright with scripting or GREP.
    Thnx.
    Gijs

    As you say, it's not waterproof, but it is really helpfull, thanks. The unclosed quotation are easy to find this way.
    In Dutch we mainly use single quotation marks (double quotation marks are only used for quotations within quotations). This brings an extra dimension to the issue, since the apostrophe and single quotation mark are the same character. So a phrase like ' I'm having problems finding unopened quotations' with your GREP suggestion will mark the apostrophe in I'm as the closing quotation mark.
    So what I'll do is:
    1. find unclosed quotations ‘[^’]+?‘ and mark them with a character style WARNING;
    2. GREP search ’[^‘]+?’ two following closing quotation marks and make them C=100;
    3. GREP search ’[^‘’]+?’ the correct quotations and mark it all K=100;
    4. Do a regular search for '^$ any apostrophe/quotation mark followed by a letter and mark them all K=100;
    5. Do a regular search for any closing quotation mark left in C=100 and manually WARNING-mark the ones that need to be looked at by the editor.
    Step 4 is a bit tricky since any error like 'I agree,'he said (no space after quotation mark) will be marked back to K=100 as well, but those errors I'll probably notice since they're underlined by the grammar control option.
    Thanks again for the help.

  • [CS3] GREP search first ocurence only

    Hi!
    I have an alphabetical list:
    Asdfg
    Awert
    Bsdfg
    Bwsd
    Csdfg
    Cwsd
    etc
    Is it possible to grep search first occurrences of A:s, B:s, C:s etc and then apply some formatting?
    ie search first line that starts with A, apply formatting, ignore following lines witch start with letter A and search first line that starts with B, apply same formatting...
    Thanks

    Oh allright, this one sets the paragraph style "Index head" as well.
    nextpar = app.activeDocument.selection[0].paragraphs[0];
    do
    nextletter = nextpar.contents[0].toUpperCase();
    nextpar.insertionPoints[0].contents = nextletter+"\r";
    nextpar.insertionPoints[0].appliedParagraphStyle = "Index head";
    while (nextpar.contents.length > 0 && nextpar.contents[0].toUpperCase() == nextletter)
      if (nextpar == nextpar.insertionPoints[-1].paragraphs[0])
       exit(0);
      nextpar = nextpar.insertionPoints[-1].paragraphs[0];
    } while (nextletter < "Z");
    It's surprisingly slow, on a 3 column/4 page index... but it still beats doin' it manually, 'cause you can sit back and clean your fingernails or something like that.

  • Question for scripting gurus: GREP search, change case make Smallcaps

    I have no knowledge of scripting at all, but this question keeps coming up during training sessions: is it possible to (java)script this:
    - Do a GREP search \u\u+
    - Change case to lowercase
    - Apply SmallCaps (or: apply character style)
    this would allow to search for acronyms and change them to smallcaps (or, even better: apply a character style with small caps and tracking)
    I know it is easy for OpenType smallcaps (do a GREP search, change to OT smallcaps) but this doesn't really change case. And some fonts used aren't OT.
    Anyone?
    Would be VERY apreciated!!

    But Harbs is a seasoned scripter who knows he'll get flamed if one of his scripts "just does not work" ;)
    Well, now that you mention it, the script is not really foolproof. It's a quick and dirty script which I threw together very quickly. It's missing any error checking, some of the variables global, and it's not in a private namespace. These are all things which could cause it to "just not work" ;-)
    Here's a more foolproof construct... (and it'll work on the current story if selected, or the whole document if there's no story selected) It will create a new character style if one does not exist and work on character styles within style groups as well. I wrapped the whole script in an anonymous function to give it a unique namespace as well.
    (function()
    if(app.documents.length==0){return}
    var doc=app.documents[0];
    // Change the following to your style name!
    var character_style_name = 'Small Caps';
    try{var range = app.selection[0].parentStory}
    catch (err){var range = doc}
    //comment out next line if you do not want styles.
    var charStyle = GetCharacterStyle(character_style_name,doc);
    app.findGrepPreferences = null;
    app.findGrepPreferences.findWhat="\\u\\u+";
    var finds=range.findGrep();
    for (var i=0;i<finds.length;i++){
    finds[i].changecase(ChangecaseMode.lowercase);
    //comment out next line if you do not want styles.
    finds[i].applyCharacterStyle (charStyle)
    //uncomment next line if you do not want styles.
    //finds[i].capitalization=Capitalization.smallCaps;
    function GetCharacterStyle(styleName,doc){
    var charStyles=doc.allCharacterStyles;
    for(var i=0;i<charStyles.length;i++){
      if(charStyles[i].name==styleName){
       return charStyles[i];
    return doc.characterStyles.add({name:styleName,capitalization:Capitalization.smallCaps});

  • GREP search crashes InDesign

    Hi,
    I have a script which imports XML and formats it. As part of the formatting, there's numerous GREP searches which remove redundant spaces, returns and so on.
    One in particular crashes InDesign and it's driving me nuts.
    It's supposed to remove redundant returns in a table:
    // GREP Search for redundant returns
    app.findGrepPreferences = app.changeGrepPreferences = null;      
    app.findGrepPreferences.appliedParagraphStyle = "ArticleMinister";
    app.findGrepPreferences.findWhat = "\r$";
    app.changeGrepPreferences.changeTo = "";
    app.activeDocument.changeGrep();
    The problem is there's an XML closing tag between the carriage return and the end of the para, i.e. data{return}</closingtag>, but it works fine when the XML is data</closingtag>{return}.
    Any assistance would be most appreciated.

    Hi Vamitul,
    Thanks very much for the reply and it makes perfect sense.
    This script creates quite a complex document and, for some reason, moving the {return} outside the XML tags makes a mess of the document. I do not know why but I suspect that some of the 'clean up' non-GREP search and replace commands in the script are ignoring the XML data - perhaps not but I cannot for the life of me work out why a simple change is making the text a real mess.
    So the 'harder fix' sounds like something worth pursuing as this is the last step in a long process. Do you have any more information about checking the xmlContents? I don't expect anyone else to do my work for me, but advanced (or even intermediate) scripting is something I struggle with.
    Cheers,
    Simon.

  • Adding GREP search to FindChangeByList script in CS4

    I'm trying to remove numbers from a baseball box score pulled from the Internet.
    The file has 10 numbers across separated by tabs and I only need six of the numbers not all 10
    St. Lucie Mets
    Player,Pos         AB     R     H     2B     3B     HR     RBI     BB     SO     AVG
    Daniel Muno, 2B    4     1     1     0     0     1     1     0     2     .259
    Robbie Shields, DH     4     0     2     1     0     0     0     0     1     .471
    This GREP search works in FindChange in InCopy/InDesign (using CS4)
    (\t\d) (\t\d) (\t\d) (\t\d) (\t\d) (\t\d) (\t\d) (\t\d) (\t\d)
    This works in the Change field
    $1 $2 $3 $7 $8 $9
    However, when I try to add this to a FindChangeByList script, it generates an error. So my syntax, logic or both is flawed.
    What should I do to fix it?
    grep    {findWhat:"(\t\d) (\t\d) (\t\d) (\t\d) (\t\d) (\t\d) (\t\d) (\t\d) (\t\d)"}    {changeTo:"$1 $2 $3 $7 $8 $9"}    {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false} Find all double spaces and replace with single spaces.
    Thank you,
    Keith

    Hi Jongware,
    Thank you for the reply.
    I tried the double slashes and get an Error 25. So something I'm doing in the Search/Replace portion isn't working.
    However, I did have success with changing a style by using a GREP search. The line below works with the double slashes, just not the Find/Change lines:
    grep
    {findWhat:"\\t\\d\\t\\d\\t\\d\\t\\d\\t\\d\\t\\d\\t\\d\\t\\d\\t\\d"}
    {appliedParagraphStyle:"Z BB Box Exp Batting 07T"}
    {includeFootnotes:true, wholeWord:false, caseSensitive:false}
    //Changes style

  • Firefox clears the searchbox on ebay when i perform a search and nothing happens!

    Firefox clears the search-box on ebay when i perform a search and nothing happens! The page just refreshes and i can't find any items. It works as normal when i try with IE though..
    == This happened ==
    Every time Firefox opened
    == about 3-4 months ago..

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.com/kb/Safe+Mode

  • Error Correlation ID: 29cb4bfc-421e-42be-9fe4-50a5c686fec4 is displayed when I perform a search on our Intranet ?

    When I perform a search on our Intranet it shows a displayed of
    Correlation ID: 29cb4bfc-421e-42be-9fe4-50a5c686fec4 I have researched the problem and it seems to be something to do with a service application but which I have created a new one but the problem is still there can anybody advise me on what other thinks could
    be wrong, or is it something I'm missing out. Thanks

    Hi Mike,
    Navigate to SharePoint server below path
    C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\LOGS
    Then open the latest log file and search the above correlation ID to find actual error.
    Thanks
    Somnath Matere

  • An error occurred attempting to perform the search. Faulty bluetooth?

    So aside from the "Bluetooth Unavailable" error that a lot of users are experiencing, I've done so much searching on my specific issue. No answers so far. I've come to the forums for help and insight.
    My bluetooth IS available. I have it set on discoverable. However, when I click to set up any device whatsoever in the Bluetooth Setup Assistant, 90% of the time, the error "An error occurred attempting to perform the search." appears next to a yellow triangle with an exclamation point inside. One in every 30 tries, it might pick up my cell phone or a bluetooth headset or a mouse. But the connection unpairs as soon as the setup process is complete. Almost all of the time, that error appears. Rarely will I get the message "No devices found." Also, my PDA and phone never see my Macbook as discoverable.
    I have three months left on the original Apple warranty. It's a refurbished Macbook 2GHz Core Duo running 10.4.10 with 2 GB of RAM. I bought it 9 months ago from apple.com. Is this mostlikely an OS X problem with Tiger or an actual hardware malfunction with the bluetooth module? Has anyone else experienced this problem?
    PS - I should mention that the same type of malfunction happens when I'm in Windows XP Professional in Bootcamp.

    Hi WizKidd,
    welcome to macbook forum.
    try to reset PRAM and or PMU to refresh your Hardware including your bluetooth.
    http://docs.info.apple.com/article.html?artnum=303319
    http://docs.info.apple.com/article.html?artnum=2238
    Also you can tun hardware test by starting using installer disk and press D key while it start up.
    If those doesn't help, consult apple care or apple store and let them examine and have it fixed.
    Good Luck.

Maybe you are looking for