GREP to Find Numbers at End of Story

I want use GREP to do a find to locate any six digit number or just the numeral zero at the end of each story in my InDesign 4 documents.
So far, I have ben able io identify six digit numbers by searching for the following \d{6} But when I add the end of story location marker,  \z\d{6}, no results are returned.
What do I need to do to:
1. get the expression to search for the number at the end of the story
2. amend my expression so that it finds either a six digit number or the numeral zero
Any help on this would be appreciated

kmc27 wrote:
In the InDesign document here isn't the six digit number in the first example and the zero in the second example at the end of the story? Wouldn't \z find these numbers?
No, to both questions.
\Z is a location marker, and it only matches the position "end of story". You have a hard return between the digits and the location 'end of story'.
This will work in your example document:
(\d{6}|0)\r\Z
and it would be wise, in your case, to mark the hard returns as 'optional':
(\d{6}|0)\r*\Z

Similar Messages

  • Find / Change Replace "End of story" by Paragraph

    Hi tehre,
    I tried unsuccessfully to find out how to manage to put a paragraph to the end of story to the multiple textframes automatically. There must be some way! Am I right?
    Thank you!

    Hi Scott,
    See the IMG please to understand me more:
    Each textframe  has the "#" hidden character on the very end. I want to put there a paragraph to the very end of each textframe I selected. I imagined something like this:
    Open "Find / Change" dialog box
    Find the "#" {End of Story}
    And replace it by "¶ #" {Put the paragraph before the very End of Story}
    I am merging multiple textframes, copy them and put the text to the different indd document. But if there is not a paragraph on the end of the textframes which I am merging, all the text joins together and I have to put paragraphs manually there afterwards. {I am merging 4 textframes into one, so i have to put there at least 3 paragraphs. I have 350 items, which means about thousand paragraphs together to be put manually.}
    Runnig ID CS6.
    Thank you!

  • Grep to find first occurrence of a particular word in a story

    Hello Grepers
    I haven't had luck working out a Grep to find first / last occurrence of a particular word in a story.
    To find the first occurrence of the word hello in a paragraph I would use this grep.
    (Hello(?!=Hello*$))
    For the last this works.
    ((?=Hello(?=.*Hello)))|(Hello(?!=Hello*$))
    I have tried single line and multiline prefixes but they don't do the trick.
    Waiting in suspence,
    Trevor

    Hi Marc,
    Thanks for your reply, I'm glad you got my subtle hints.
    1) First Hello in the paragraph(s)
    Marc Autret wrote:
    Also, it seems to me that the GREP patterns you've posted are wrong and only work by accident. For example:
    (Hello(?!=Hello*$))
    actually means: find 'Hello' if and only if the match is not followed by '=Hell' and 'o' zero or more times and an EOL.
    Well Marc I made a Hell of a mistake!!!
    I meant to write (Hello(?!=Hello.*$)) with a dot there which at least is not quite as stupid if not more correct.
    In fact both (Hello(?!=$)) without a . and Hello(?!=^) work, well sort of work for the first Hello of the paragraph(s) depending on the were one start the search from (before the first Hello works otherwise it will find the next "first" Hello of the paragraph.
    I said sort of because I naively presumed that GREP styles would work like GREPS, dumb hey.
    I was really looking to use these GREPS in GREP styles, well you can't.
    In a GREP style
    (Hello(?!=$)) or any of its variants will apply the style to all occurrences of Hello in the paragraph.
    I can partially circumvent this problem by adding a second GREP STYLE which applies an anti style to all words after the first Hello (?<=Hello).*
    i.e. I have a want my first Hello to be bolded then set the first style for bold and the second to regular.
    This however is not practical if one wants to auto style more than one word in this way in other words to do the same for the first Hi and the first Hello in the paragraph.
    As a regular GREP solution providing that one starts the GREP search before the first occurrence of Hello It will work.
    2 & 4) First and Last Hello in the story
    Again these GREPs don't work using GREP styles, this I think is because GREP paragraph styles only look within the one paragraph at a time they are applied to.  So they can't look at the preceding or following paragraphs to see if they contain Hello or not.
    If I am correct I see no work around to this and am will to pay 10 Pounds, Euros or Dollars to whoever comes up with a non-script fully functional  GREP styles solution for this (I think my money's safe)
    Regarding the regular non styled GREPs they nearly work as stated.
    When (?s)(Hello)(?!.*?\1) is used to find the last occurrence of Hello in the story, if the find tab is used it will firstly find the last Hello of the story then it will go back and find the one before that!! then it will go onto the next story.
    Using the GREP in script works as stated.
    The easiest way of course to find the first and last Hello in a story, document etc. by script would be
    app.findGrepPreferences.findWhat = Hello"
    myFinds = myWhatEver.findGrep();
    First occurrence   myFinds[0], last occurrence   myFinds[-1].
    HOWEVER NOT PARTICULARLY EFFICIENT!
    3) Last occurrence  of Hello in paragraph.
    This one works perfectly both with regular GREPS and GREP styles.
    In summary
    GREP STYLES: only the (Hello)(?!.*?\1) last Hello in the paragraph GREP works.
    GREP FIND TAB: the first Hello in the paragraph GREP finds the first Hello after the cursor, the first in the story works in the limited way as written, last in story has the problem of finding the second last Hello after finding the last Hello, Last in paragraph works flawlessly.
    GREP SCRIPTING: all work without problem except for the first Hello in the story that has the problem of needing to extract the last 5 letters which for my automatic text / GREP changer is a bit of a problem but for general scripting would not be problematic.
    Once again Marc thanks for your input, I doubt there's much if anything  to add on the topic maybe Laurent Tournie from indigrep.com might have some ideas.  I don't know his contact details so if you think it's a good idea please can you send him a tweet / mail.
    Regards
    Trevor

  • 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

  • Add glyph at end of story...

    Hi,
    trying to do a find/ change where I need to add a glyph to the end of a story. I have a bunch of titles in their own text frame which also have their own paragraph style and I want to add a right indent tab, then a glyph after the last word in that title.
    Can anyone help me with the grep expression?
    Thanks,

    You spotted an 'error' (some might call it a vaguery) in the grep search&replace. ID won't allow 'replacing' a
    i position marker
    with anything. So you can't, for example, add something at the start of each paragraph using just "^" in Search.
    This goes for all positions -- '^' and '$' (start and end of para) and '\A' and '\Z' (start & end of story); probably for the others as well (start/end of word? likely).
    That said, a better search & replace is the following:
    Find: .\Z
    Replace: $0~y>
    .. so the Find text will find
    i any
    character (the '\w' only specifies alphanumerics). The $0 in the Replace is a tiny refinement: because you 'use' your entire Found text -- the '\Z' is discarded --, you don't have to use parentheses and can use '$0' in the Replace, meaning "the entire Found text".

  • 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

  • Search for end-of-paragraph before end of story? CS6

    Hi,
    Does anybody know of a way to search for a paragraph mark directly
    before an end of story marker? I'd like to get rid of them, e.g., in
    footnotes, where the last paragraph mark causes an unnecessary blank line.
    Thanks,
    Ariel

    I found \z on Mike Witherell's great little chart at http://www.jetsetcom.net/useful-resources/indesign-cs6-resources.html
    End of paragraph, at least in GREP is a location, not a character (the metacharacter is $) and can't be selected or replaced. Every paragraph has one. Paragraphs before the end of story also have a paragaph break, and that's what you are trying to remove at the end of your footnote story.
    @David, Why bother withthe lookahead? \z is the location, so I would presume that the search would start at the end of story and look at the last character. That has to be faster than parsing every break in the paragraph to check for the end of story location after, and there's no possibility that you will actually delete the EOS since it can't actually be selected.

  • Drag and drop not working.  When trying to move a cell or icon the shadow of the cell or icon being moved appears under the cursor but can't be released causing a freeze of function within the program.  Happens in finder numbers and firefox

    Drag and drop not working.  When trying to move a cell or icon the shadow of the cell or icon being moved appears under the cursor but can't be released causing a freeze of function within the program.  Happens in finder numbers, firefox, and when trying to move any file from the downloads folder.
    This is a serious pain.
    Please help.
    WB

    Yes, all I can tell you is that Finder does not have that function in ML. Your system is "working as expected".
    You can file feedback here.

  • Find start and end execution time of a sql statement?

    I am have databases with 10.2.0.3 and 9.2.0.8 on HP UNIX 11i and Windows 200x.
    I am not in a position to turn on sql tracing in production environment. Yet, I want to find when a sql statement started executing and when it ended. When I look at v$sql, it has information such FIRST_LOAD_TIME, LAST_LOAD_TIME etc. No where it has information last time statement began execution and when it ended execution.. It shows no of executions, elapsed time etc, but they are cumulative. Is there a way to find individual times (time information each time a sql statement was executed. – its start time, its end time ….)? If I were to write my own program how will I do it?
    Along the same line, when an AWR snapshot is shown, does it only include statements executed during that snapshot or it can have statements from the past if they have not been flushed from shared memory. If it only has statements executed in the snapshot period, how does it know when statement began execution?

    Hi,
    For oracle 10g you can use below query to find start and end time, you can see data for last seven days.
    select min(to_char(a.sample_time,'DD-MON-YY HH24:MI:SS')) "Start time", max(to_char(a.sample_time,'DD-MON-YY HH24:MI:SS')) "End Time", b.sql_text
    from dba_HIST_ACTIVE_SESS_HISTORY a,DBA_HIST_SQLTEXT b where
    a.sql_id=b.sql_id
    order by 1;
    Regards
    Jafar

  • Spotlight doesn't find "numbers," in Numbers.  Way to fix that?

    Hi.
    With Excel documents, Spotlight finds numbers within the document. i.e. an invoice number, an amount, etc.
    However, Spotlight is not finding any numbers inside my Numbers documents.
    Is there anyway to change or fix this? THanks for the help. Even if there is a third party way or something? Thanks!

    i can imagine why spotlight does no indexing on data inside cells... it looks to me pretty useless to index files that have hundreds of reoccurring numbers numbers and numbers - would you like to have an overview of all files that has the number 6 in it, or 51.... and than to think of it that a lot of numbers in a table are not numbers at all, but only calculations
    however, there is a way to get spotlight informed:
    use the inspector, document (most left tab) there is a option to set various spotlight hints like author, title, keywords and comments
    hope that will help
    wished that Numbers and others were more scriptable, so i could get some cell contents and paste it into the keyword field there

  • How to find out back end mapping program for Idoc ?

    HI Experts,
    Iam new to ALE IIDOCS .. i have a issue in existing idoc .
    Some data maping problem is there in the existing idocs
    I need to find out back end program for this perticular idoc  no .
    Exactly where they have written the maping code  .
    How to find out this ?
    is there any preceedure to trace the back end program based on the idoc number .
    Regards
    RameshG

    Hi Ramesh,
    If you are looking at Inbound que then we generally double click on idoc go to control datat info and then take partner data info there
    Goto we20 check teh system and there double click the message type and there in inbound option double clik the porcess code it gives you one FM where you can see logic written to process that IDOC
    Regards,
    Poornima

  • Spotlight in "Open Dialog" fail to find "Numbers" file

    Hi,
    when i use the spotlight search tool inside the open dialog box from Numbers it seem to be unable to find "Numbers file".
    Let say I have 4 files on my Hard Drive :
    - FileName1.xls
    - FileName1.Numbers
    - FileName2.xls
    - FileName2.Numbers
    If I type "FileName" in Finder > Spotlight It get all the 4 files.
    If I type "FileName" in Numbers > Open Dialog > Spotlight it get :
    - FileName1.xls
    - FileName2.xls
    Either I check or not different search options (filename / content / Start / My iMac ...)
    Any idea what's wrong ?
    Thank you.

    Bonjour,
    Concernant votre dernier message :
    oui, j'ai vu votre capture. C'est du Page, pas du Numbers :-) une différence serait possible, mais lire la suite ci-dessous...
    La corruption d'index est une piste. Mais comme Spotlight trouve mes fichiers dans d'autres conditions, cela indiquerait un Index correct. Toutefois, ce point est très technique et je ne ferrais aucun pari sur la "mécanique" d'Index Spotlight. J'ai donc utilisé l'outils recommandé dans la discussion donnée en lien (je n'aime pas trop l'idée qu'un outil tiers bidouille les entrailles de l'OS d'Apple, mais bon). Apparemment l`'outils détruit l'index et Spotlight se met au travail et ré-index le disque.
    Mais cela n'a rien changé.
    j'aimerais approfondire un peu si vous le coulez bien. Avec 37 805 points vous devez avoir quelques ressources en réserves ;-)
    Appelons ça le "bogue" ; même s'il peut s'agir d'un problème de paramètre quelconque modifié maladroitement dans mes préférences systèmes ... En explorant différentes pistes et en vous les soumettant je peux peut être vous mettre sur la voix d'une solution qui ne vous vient pas immédiatement à l'esprit car très spécifique à mon cas particulier.
    Nous sommes d'accord sur ce point : la recherche dans Numbers > Ouvrir est une implémentation de Spotlight. Manifestement cette implémentation est pleines d'options et présente des différences significatives avec le Bureau.
    Exemple 1 :
    Dans Finder la recherche par type > autre est un champ vide.
    Dans Numbers la recherche par type > autre est une liste de choix.
    Il semble que Spotlight dans Numbers ne prennent en considération que les fichiers que Numbers peut ouvrir. Et pour cela il se base sur l'extension. Et le bogue fait penser que les développeurs auraient oublié l'extension ".numbers" !
    ------------ EDIT
    J'ai effacé tout une série de tests tant la découverte finale est la plus importante ...
    En modifiant l'extension d'une application en .numbers elle est apparue dans ma fenêtre Numbers !
    J'en conclu que "mon" Numbers n'affiche via spotlight QUE les fichiers portant une extension compatible (xls, cwk, txt) ET que le fichier est de type "binaire / app / ???".
    L'erreur serait sur ce dernier aspect : les fichiers numbers ne sont PAS des fichiers "binaire / app".
    Ou orienter les recherches, puisque, manifestement, ça marche sur votre Mac ?
    Merci d'avoir étudier cette longue réponse.
    --Edit
    Numbers trouve les .php (des fichiers text assimilable à des executables) mais ils sont grisés donc impossible de les ouvrir.
    Là je dis, ça devient du n'importe quoi .... :-(

  • I have a mac/downloaded latest adobe reader & cannot find to accept end license agreement

    I have a mac/downloaded latest adobe reader & cannot find to accept end license agreement.  It says downloaded successful.  I go to use it and it won't work.  Said to close.  I've opened adobe reader again and brings me back to install which I hit again and it says already installed. 

    I am having this same issue, which is frustrating.  How does Adobe not have weekend tech support?  I keep getting told to just "open the program"  well, i have tried to open it, and it doesnt show as downloaded, so i will go to download it, and it says "you already have this installed"... well okay, then i go to find it, and it doesnt exist anywhere on my computer and tells me to download it again, and annoying triangle i keep going in.

  • Find/change using end of paragraph marker /p

    Folks,
    We are attempting to remove a space at the end of a paragraph in unstructured documents.  If I enter ' \p' in the Find text field in the Find/Change dialog FrameMaker finds the the appropriate paragraphs.  If I then enter '\p' in the Change text field in the Find/Change dialog and click Change the space is removed.  However the target paragraphs style is also applied to the the following paragraph.  This occurs in FrameMaker 8,9 & 10.
    If the Find/Change scenario above is followed with these two paragraphs the first paragraphs style is applied to the second paragraph.
    paragraph 1 with a trailing space and using Heading 1 style
    paragraph 2 using Heading 2 style
    Any thoughts?
    regards
    Jon

    JonEBe wrote:
    Arnis,
    Thanks!
    Yes why bother indeed!  I am at the end of a rather lengthy process to convert the creation and output of Framemaker documents into a database with a web front end.  As part of this the existing documents are imported to save lengthy keying/rekeying.  The output from the system is then compared against the originals.  As a matter of course I stripped of leading or trailing spaces (it is amazing how many there are in a manually created/updated document) so we therefore have noisy comparison documents as a result.
    BTW the trailing spaces are apparently a legacy of the conversion from WordPerfect.
    My choices are to re-import without stripping the trailing space and remove them at a later date or create a script using the FDK, which I am very familiar with, and is the likely outcome!
    Jon
    Just a wild thought - a real GREP processor, not the mild imitation in FrameMaker, can find a construction like a space followed by a paragraph marker and delete the space without affecting the marker. The technique is a form of the "lookbehind" or "lookahead" feature. I'm zero-skilled at actually doing this beyond just mentioning it, but the technique might work in a MIF, or text conversion, of the file. Search Google for terms like "GREP lookbehind lookahead," without quotes.
    Another possibility is that once the FrameMaker file is converted to the database, it would be possible to use a database command to remove the space.
    HTH
    Regards,
    Peter
    Peter Gold
    KnowHow ProServices

  • Applescript to add numbers to end of folders names

    Hello,
    I wrote a script that can rename files and add sequential numbers to them (below):
    set theResult to display dialog "Please enter a name and a number separated by a space." default answer "enter image name here + space + 1" buttons {"Cancel", "OK"} default button 2 with icon 1
    set theText to text returned of theResult
    set theNumber to last word of theText
    set theOffset to offset of theNumber in theText
    set theName to text 1 through (theOffset - 2) of theText
    set k to theNumber as integer
    global theMaximumLength
    tell application "Finder"
      set theFiles to files of front window
      set theMaximumLength to length of (k - 1 + (count theFiles) as text)
      repeat with thisFile in theFiles
      set theExtension to name extension of thisFile
      set theNumber to my addZeros(k as text)
      set the name of thisFile to theName & "_" & theNumber & "." & theExtension
      set k to k + 1
      end repeat
    end tell
    But I want to write a script that will JUST add and _1 to the end of multiple folders.  In other words, take a bunch of folders already created like
    342392501
    342392401
    340766601
    340766201
    339898101
    339828301
    339171301
    337245001
    337086803
    337086802
    337086801
    and add _1 to all of them.  BUT what would be even better would be a script that would duplicate each folder and ad an _1 to the original and then an _2 to the duplicate, and do that for all the folders in the finder.
    Anyone?  Thanks so much!!!!

    Use code such as the following:
    set the_list to "80
    81
    82"
    tell application "Finder"
    set target_folder to (choose folder)
    repeat with this_number in paragraphs of the_list
    set this_folder to (make new folder in target_folder with properties {name:this_number})
    set name of (duplicate this_folder) to name of this_folder & "_2"
    set name of this_folder to name of this_folder & "_1"
    end repeat
    end tell
    Or to save a step if the creation dates don't need to match exactly:
    set the_list to "80
    81
    82"
    tell application "Finder"
    set target_folder to (choose folder)
    repeat with this_number in paragraphs of the_list
    set this_folder to (make new folder in target_folder with properties {name:this_number & "_1"})
    set this_folder to (make new folder in target_folder with properties {name:this_number & "_2"})
    end repeat
    end tell
    (110675)

Maybe you are looking for