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.

Similar Messages

  • Indesign grep search on page by page using javascript

    Hi,
    Is it possible to grep search a word page by page instead of searching in whole document..
    If it is possible, please suggest how to do this.
    Thanks,
    Gopal

    Hi Gopal,
    You can't search directly in page. Instead you can search by pages[n].textFrames[x].texts[0].findGrep().
    Regards,
    Ramkumar .P

  • Process Indesign Grep Search

    Hi
    I'm using the following script, to search for fixture times within an InDesign Document.
    Unformatted InDesign text would be…
    Monday 19 March
    Gates 1.23 am First 4:56pm   Last RACE 7.12pm
    Applescript is:
    tell application "Adobe InDesign CS3"
       --Clear the Find/Change fields
       set find text preferences to nothing
       set change text preferences to nothing
       --Set FindWhat/ChangeTo values
       set find what of find grep preferences to "(\\n|\\r)[Gg][\\u\\l ]+(\\d+)[.:](\\d+)[\\u\\l ]+(\\d+)[.:](\\d+)[\\u\\l ]+(\\d+)[.:](\\d+)[\\l\\u]+"
       set change to of change grep preferences to "$1Gates Open $2.$3am First Race $4.$5pm Last Race $6.$7pm"
       --set the find options
       set include footnotes of find change grep options to false
       set include hidden layers of find change grep options to false
       set include locked layers for find of find change grep options to false
       set include locked stories for find of find change grep options to false
       --Do It
       change grep
       set find grep preferences to nothing
       set change grep preferences to nothing
    end tell
    This is working for me as a clean up on the structure and formatting, however I would now like to process the AM and PM based on the times (Rule all First & Last Race times will always be PM, Gates Open can be both)
    What I'm thinking is to get the times grep returns, query them, then set Am or PM to the string depending on the result.
    My problem!
    When I "return find grep preferences"
    I get this...
    {text from character 16 to character 61 of story id 191 of document "Gates Grep.indd" of application "Adobe InDesign CS3", text from character 16 to character 66 of story id 379 of document "Gates Grep.indd" of application "Adobe InDesign CS3"}
    I would like to get the separated numbers and put them in to a list
    eg. {"1","23", "4","56","7,"12"}
    Thanks for any help on this
    LJ

    I know absolutely nothing of AS, but it might be worth pointing out that GREP (and regular findText as well) does not return regular text, but rather an array of pointers to InDesign formatted text. In JavaScript, you have access to the plain ASCII string using text.contents -- AS might be able to do the same.
    .. the separated numbers ..
    Your example list does not contain numbers but strings, which will lead to problems if you try to compare them ("2" being larger than "10"). Don't forget to convert them to numbers before comparing.

  • 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.

  • 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.

  • 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…

  • 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});

  • 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

  • CS3: grep search to replace part of a string

    Can I do a grep search for a string of text but only replace a portion of the string while leaving the remainder intact?
    iMac G5, OS 10.5.5

    In addition to Eric:
    Find "some search string", Replace "some replacement string " also replaces part of the string, not touching anything...
    But the GREP search has two advantages: First, if you define formatting in the Replace field (italics, superscript, a character style), only the 'search'/'replacement' part will be affected, rather than the entire found string (as in regular search).
    The second big advantage is you can use any regular GREP single character wildcard in the 'left' and 'right' (matching-but-not-marking) parts. A few useful examples: '\d' (digit), '\l' and '\u' (lowercase and uppercase), '.' (any character), or even '[a-f]' (lowercase 'a' to 'f'). The only limitation is that you cannot use the once, zero-or-more, or once-or-more modifiers -- the strings must have a fixed length. FYI, those three modifiers are, respectively, ?, *, and +.
    This restriction does not apply to the 'middle' string, the one you are going to replace anyway -- use whatever GREP you want.

  • GREP searches from top of story?

    I've set up a GREP expression to find some material I need to delete, but I need to check each instance before I actually delete it. Unfortunately, the GREP expression occasionally finds text that I want to keep, so it's not bullet proof.
    When I first set up my GREP expression, it worked fine -- it would find the next occurrence of the expression after the insertion point when I type a keyboard shortcut for the "GREP Find Next" command.
    Suddenly, and I don't know why, it changed its behavior so that instead of finding the next instance of the GREP expression after the current insertion point, it finds the first occurrence in the story, which is pages away from where I want to be working.
    Is there some way to tell GREP (or any Find search) to look from the insertion point rather than from the top of the document? It seems to have both behaviors as options, but I don't know why it chooses one over the other.

    Well, having done a little more work, I think the problem may result from a look-behind that I added to the beginning of the string.
    Basically, I have about 500 abstracts, each has a long list of authors, with punctuation as follows: SMITH, J.S., affiliation, email; JONES, S.J., affiliation, email; etc.
    I need to get rid of the affiliations, emails, and semicolons; keep the Author name and initials; and apply a script of mine to put the last name in title case, resulting in
    Smith, J.S., Jones, S.J., etc.
    There are some typos and unusual names, so I need to do this one by one rather than with a global search, but I want to be efficient. I want to run my case-change script on the last name, then trigger a GREP search that will select the affiliation and email, which I can then look over to confirm, then delete. (Affiliation may be full of all kinds of punctuation).
    Currently I'm using
    .+?[;\r]
    ...which selects from the insertion point to the next semicolon or the end of the paragraph, whichever comes first. This one works, but I first need to move the insertion point past the initials, which takes more keystrokes.
    Since the author initials always end with a period followed by a comma, but I don't want to delete those, I thought I'd add a look-behind so that the GREP would select all the text from (but not including) a period-comma to (and including) the next semicolon:
    (?<+\.,).+?[;\r]
    The problem is that instead of searching from the insertion point, it goes to the beginning of the file and grabs the first occurrence of the pattern, which is the first already-corrected address (since there are no semicolons left, it selects from just after the first author's initials to the paragraph end).
    Anyway, if anyone has some ideas (including "sorry, GREP just behaves this way with look-behinds") I'd appreciate any help.

  • GREP - search for anything except one character

    Trying to figure out if I can say this in GREP or not....
    I want to search for any character that's in a Superscript character style except for registration-mark symbols.  Is there a way to exclude one character from a search?
    Thanks, Phyllis

    Absolutely. Remember the '^' character that indicates 'start of paragraph'? Well ... apparently whoever devised GREP ran out of useful characters, because it's used again in the "exclude" group. It works like this:
    [0-9fuzzy]
    looks for a single character out of the set '0' to '9' (inclusive), 'f', 'u', 'z', or 'y'. Throwing in the hat reverses the query:
    [^0-9fuzzy]
    looks for any old single character except those in the set.
    The Registered mark has a shortcut of its own in the regular Find -- ^r -- so presumably it's "~r" in GREP mode. If not, copy-and-paste one from your text. So your GREP search should be (with Superscript formatting)
    [^~r]
    This marks only the next non-registered character; to find longer strings you can safely use
    [^~r]+
    -- which translates into "any string in superscript, one character or longer, and not containing the Registered mark". Yes, the short version is a bit easier to type.

  • Functionality loss when 'Using Query Bind Variables in Advanced Search

    Regarding: 'Using Query Bind Variables in Quick or Advanced Search'
    The functionality to do the following is lost when I use bind variables in the Advanced Search:
    "Result matches all conditions"
    "Result matches any condition"
    "Case Sensitive?"
    Is there a way to Search with Detail groups but to keep the above functionality?

    Hi,
    Your application module impl java class extends the JHeadstart class JhsApplicationModuleImpl. THe latter declares a method:
    public void advancedSearch(String viewObjectUsage,java.util.ArrayList arguments,Boolean allConditionsMet).
    In your application module impl java override the advancedSearch method where you can include your own custom code before invoking the super method:
    super.advancedSearch(viewObjectUsage,arguments,allConditionsMet);
    The 'arguments' parameter is an arraylist of QueryCondition objects. You can set several properties for QueryCondition objects such as case-sensitity, operators etc.
    Regards,
    Ibrahim

  • [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.

  • 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.

  • Use of KM services and TREX Search Engine From share point portal

    Hi All,
    We would like to  Use of KM services and TREX Search Engine From share point portal.
    For this purpose we interoperability between windows sharepoint and SAP Portal.
    Please provide necessary documents or suggestions for interoperability for above requirement.
    mail id : <b>[email protected]</b>
    Thanks in advance
    Regards
    Swarna B

    Hi,
    See this this links:
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/9e891378-0601-0010-5386-a3387f1b161b
    Regards,
    Senthil K.

Maybe you are looking for

  • Ethernet/internet security settings

    Hi I'm wondering what is the best, safest way I should set my Ethernet settings (in the Network section of 'System Preferences') to keep my internet connection safe from anyone trying to scam on my connection. by the way, I'm using an Unwired modem.

  • Not showing the tables of sql server in webspher

    hi all i am using sql server 2000 and websphere 5.1. i am trying to connect to any database (say master) in user sa of sql server. my driver is WebSphere Connect JDBC Driver. it is connecting the databale. but not showing the tables. even i had tried

  • How To Save A Document With Lion X

    What exactly do I do to save a document with iWork 09, Pages, and Lion on an up to date 10.7.1?

  • Binding a component to a property and GUI update

    I have a problem regarding the following code: <h:selectBooleanCheckbox id="chackBox" rendered="false" binding="#{BackingBean.newsletter}" /> <h:outputLabel for="newsletterLabel" rendered="false" binding="#{BackingBean.newsletterText}" > <h:outputTex

  • Error Log in E-Commerce CRM B2B with SU01 user

    Hi guys, I´m configured ISAUser Admin with value "CRM_SU01UserID" for component usertype in http: //server:port/isauseradm/admin/xcm/init.do. Also I´m configured my scenario B2B with value "CRM_SU01UserID" in component usertype. In rute Customer Rela