Find/Replacing numbers in document problem

I have a large document that I need to replace the numbers from 1-10 with letters.
The problem with doing an automatic replace is that it will affect numerals like 1.5 and numbers 11 and over. Is there any way to get around this or am i doomed to go through the entire document?

First: if I am not mistaken you will need to do a replace for every single number, i.e. you need ten passes. Get yourself acquainted with the "FindChangeByList" script in your script-panel.
To rephrase: you want to replace any digit that is neither preceded nor followed by either another digit or a dot. Correct?
Then you can grep for this: (?<![\d.])1(?![\d.]) and change to a

Similar Messages

  • HT2488 Find/Replace text in document with automator: any suggestions?

    I'm looking to replace a number of unique html tags for a number of documents: is there any way to do this without going through the documents one-by-one, tag-by-tag? I would imagine I might be able to do something with automator, but I'm open to any other suggestions. I have some knowledge of html, but that's about it.

    So I take it this is something you do regularly, not something that needs to get done once?  if it were a oneshot operation it would be simpler to use TextWrangler.
    For repeated use, the simplest approach is to run through the files and apply text item delimiters to each tag:
    set indesignTags to {"idtag1", "idtag2", "idtag3"}
    set htmlEquivs to {"htmltag1", "htmltag2", "htmltag3"}
    set theFiles to choose file with prompt "Choose indesign files" with multiple selections allowed
    repeat with aFile in theFiles
      -- get file text
              set fileText to read aFile
      -- swap tags
              repeat with i from 1 to count of indesignTags
      -- swap lead tags
                        set fileTextBits to tid({input:fileText, delim:"<" & item i of indesignTags})
                        set fileText to tid({input:fileTextBits, delim:"<" & item i of htmlEquivs})
      -- swap trailing tags
                        set fileTextBits to tid({input:fileText, delim:"</" & item i of indesignTags})
                        set fileText to tid({input:fileTextBits, delim:"</" & item i of htmlEquivs})
              end repeat
      -- make new file path with html extension
              set oldFilePath to POSIX path of aFile
              set filePathBits to tid({input:oldFilePath, delim:"."})
              set last item of fileNameBits to "html"
              set newFilePath to tid({input:filePathBits, delim:"."})
      -- save at new file path
              set fp to open for access newFilePath with write permission
      write fileText to fp
      close access fp
    end repeat
    on tid({input:input, delim:delim})
      -- handler for text items
              set {oldTID, my text item delimiters} to {my text item delimiters, delim}
              if class of input is list then
                        set output to input as text
              else
                        set output to text items of input
              end if
              set my text item delimiters to oldTID
              return output
    end tid
    This will work if the indesign tags are unique and there is no complex syntax.  It might fail if tags have overlapping names (e.g. "<bl>" and "<blue>") or if there's any irregular notation.  If you need more sophisticated handling you'll have to use regular expressions.  In that case, download and install the Satimage osax from this page, and use the following (similar) code:
    set indesignTags to {"idtag1", "idtag2", "idtag3"}
    set htmlEquivs to {"htmltag1", "htmltag2", "htmltag3"}
    -- set up regular expressions change lists
    set findList to {}
    set changeList to {}
    repeat with i from 1 to count of indesignTags
              set end of findList to "(</?)" & item i of indesignTags & "(?![[:alnum:]])"
              set end of changeList to "\\1" & item i of htmlEquivs
    end repeat
    set theFiles to choose file with prompt "Choose indesign files" with multiple selections allowed
    repeat with aFile in theFiles
      -- get file text
              set fileText to read aFile
      -- swap tags - needs Satimage osax
              set fileText to change findList into changeList in fileText with regexp
      -- make new file path with html extension - needs Satimage osax
              set oldFilePath to POSIX path of aFile
              set newFilePath to change "\\.[^.]+$" into ".html" in oldFilePath with regexp
      -- save at new file path
              set fp to open for access newFilePath with write permission
      write fileText to fp
      close access fp
    end repeat
    Message was edited by: twtwtw - I made an error in the second regular expression.  should be "\\.[^.]+$", not "\\..*$".  fixed in text.

  • Find/replace and regular expression problem

    Hello, i'm using find and replace with a regular expression
    for the first time. I have it checkmarked and it's finding my text
    but it's missing (not highlighting) the ')' at the end of the line.
    Here's my code:
    [($[0-9]+<font size="-2">US</font>)]
    it's supposed to find everything inside the square brackets -
    but it misses the closing parenthesis after </font>. I need
    to find this string and replace with nothing to remove the string
    from any/all pages. Is there a reason why it's missing the closing
    parenthesis? I was actually able to add a few more parenthesis
    (e.g. "))))") before OR after the closing square bracket and it
    still found the original text minus the closing bracket and the
    extra parenthesis didn't prevent the text from being found.
    Any help is appreciated!
    James...

    WyattEA wrote:
    > Hello, i'm using find and replace with a regular express
    for the first time. I
    > have it checkmarked and it's finding my text but it's
    missing (not
    > highlighting) the ')' at the end of the line. Here's my
    code:
    >
    > [($[0-9]+<font size="-2">US</font>)]
    That's not how square brackets work
    Try:
    \(\$\d+<font size="-2">US</font>\)
    A left parens, followed by the dollar sign, followed by at
    least one
    digit, followed by <font size="-2">US</font>,
    followed by a right parens.
    Mick
    >
    > it's supposed to find everything inside the square
    brackets - but it misses
    > the closing parenthesis after </font>. I need to
    find this string and replace
    > with nothing to remove the string from any/all pages. Is
    there a reason why
    > it's missing the closing parenthesis? I was actually
    able to add a few more
    > parenthesis (e.g. "))))") before OR after the closing
    square bracket and it
    > still found the original text minus the closing bracket
    and the extra
    > parenthesis didn't prevent the text from being found.
    >
    > Any help is appreciated!
    >
    > James...
    >

  • Automator--find, replace

    How do I make an Automator script that will take a folder of text files and do a find & replace on each document?
    These are txt files, relatively short, with one or 2 strings that I want to replace with other strings. Like to make this so it will do it for each txt file in a folder.
    Thanx

    HI, according to this page, which looks as though it's a straight lift from the Microsoft help pages:
    "You can't type merge field characters («« »») manually or use the Symbol command on the Insert menu. You must use mail merge."
    Doesn't look promising, I'm afraid.

  • Find & replace part of a string in Numbers using do shell script in AppleScript

    Hello,
    I would like to set a search-pattern with a wildcard in Applescript to find - for example - the pattern 'Table 1::$*$4' for use in a 'Search & Replace script'
    The dollar signs '$' seem to be a bit of problem (refers to fixed values in Numbers & to variables in Shell ...)
    Could anyone hand me a solution to this problem?
    The end-goal - for now - would be to change the reference to a row-number in a lot of cells (number '4' in the pattern above should finally be replaced by 5, 6, 7, ...)
    Thx.

    Hi,
    Here's how to do that:
    try
        tell application "Numbers" to tell front document to tell active sheet
            tell (first table whose selection range's class is range)
                set sr to selection range
                set f to text returned of (display dialog "Find this in selected cells in Numbers " default answer "" with title "Find-Replace Step 1" buttons {"Cancel", "Next"})
                if f = "" then return
                set r to text returned of (display dialog "Replace '" & f & "' with " default answer f with title "Find-Replace Step 2")
                set {f, r} to my escapeForSED(f, r) -- escape some chars, create back reference for sed
                set tc to count cells of sr
                tell sr to repeat with i from 1 to tc
                    tell (cell i) to try
                        set oVal to formula
                        if oVal is not missing value then set value to (my find_replace(oVal, f, r))
                    end try
                end repeat
            end tell
        end tell
    on error number n
        if n = -128 then return
        display dialog "Did you select cells?" buttons {"cancel"} with title "Oops!"
    end try
    on find_replace(t, f, r)
        do shell script "/usr/bin/sed 's~" & f & "~" & r & "~g' <<< " & (quoted form of t)
    end find_replace
    on escapeForSED(f, r)
        set tid to text item delimiters
        set text item delimiters to "*" -- the wildcard 
        set tc1 to count (text items of f)
        set tc2 to count (text items of r)
        set text item delimiters to tid
        if (tc1 - tc2) < 0 then
            display alert "The number of wildcard in the replacement string must be equal or less than the number of wildcard in the search string."
            error -128
        end if
        -- escape search string, and create back reference for each wildcard (the wildcard is a dot in sed) --> \\(.\\)
        set f to do shell script "/usr/bin/sed -e 's/[]~$.^|[]/\\\\&/g;s/\\*/\\\\(.\\\\)/g' <<<" & quoted form of f
        -- escape the replacement string, Perl replace wildcard by two backslash and an incremented integer, to get  the back reference --> \\1 \\2
        return {f, (do shell script "/usr/bin/sed -e 's/[]~$.^|[]/\\\\&/g' | /usr/bin/perl -pe '$n=1;s/\\*/\"\\\\\" . $n++/ge'<<<" & (quoted form of r))}
    end escapeForSED
    For what you want to do, you must have the wildcard in the same position in both string. --> find "Table 1::$*$3", replace "Table 1::$*$4"
    Important, you can use no wildcard in both (the search string and the replacement string) or you can use any wildcard in the search string with no wildcard in the replacement string).
    But, the number of wildcard in the replacement string must be equal or less than the number of wildcard in the search string.

  • Find & Replace problem

    I have a number in a cell formula. When I search for the number with Find, it is not found. I opened the Find & Replace window and select Formulas Only and the number is found. When I select Entire Document the number is only found if the formula is open on the sheet. I would think that Entire Document would include formulas, even if they aren't open at the time. Anyone else had this problem or know a solution? I am using v2.0.3(332).

    I think it is Entire Document as opposed to Current Sheet Only, neither of which look in formulas. What you are wanting is a separate setting for Exclude Formulas, Include Formulas, or Formulas Only. That sounds like it would be useful. If you would like to suggest this to Apple, in the Numbers menu is a selection for Provide Numbers Feedback.

  • Find/replace window in Mac OS - how to attach to main document window?

    At work I use Windows and the find/replace window is part of the main document window. At home, I use Mac OS and the find/replace window is a separate floating window which is annoying because it means I'm constantly dragging it out of my way...is there a way to attach it to the the main document window on Mac ?

    It works!  Thank you.  The strange thing is, I already had a check mark on it, but I unchecked it and then rechecked it and it worked.
    BTW, I've not visited this forum for quite a while.  It was difficult to find my way to the InDesign Discussions.  There's so much stuff in between logging on to Adobe Forums and getting to this location.  I consider the changes a huge step backward.  I realize that you're probably not involved in it, but I hope someone who is sees this feedback about the forum layout.  Fortunately, it's only a one-time problem.  I've made a new bookmark for this forum.

  • Has anyone experienced an unintended "find/replace all" in a document (using FM11) ?

    Hi All,
    Using FM11 with Windows7.
    We have a problem with the following:
    If I have completed a Find/Change All in Document A (then close the Find window), then I open Document B and press Control-F to perform a new search, once I start typing the previous word search/change all is applied to Document B when it's not the intention.
    The problem is when Control-F is pressed the last function is highlighted (in this case "Change All") - rather than the word field, so nothing is actually being typed in this field - rather it performs the last function.  The basic work-around is just to make sure we click or tab to the desired field before typing...  OR make sure to delete the previous find/change text fields before closing the window.  When doing things quickly though we may forget - so it gets annoying when we have to fix this or revert to last saved document.
    Users with XP don't experience this. Each time control-F is pressed, the Find term field is the highlight so the new term is typed in as expected.
    Any tips would be welcome. 
    Thank you,
    Tina

    Tina,
    There's been a change in behaviour with FM11's Find/Change (as you've noticed). The dialog now retains focus after a search has been performed and is modal. However, the focus of the field for ctrl-F should place it in the Text area, regardless of platform, not execute the last operation. This is buggy behaviour and I just confirmed this on my platform (regardless of whether your in Doc A or B).
    Please file a bug report at the FrameMaker Bugs & Wish List  (https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform&product=63)

  • Problem Pasting into Find/Replace in DW8

    I am using DW 8, working thru a training book and when I do
    the steps of the exercise for copy, then use Find/Replace and paste
    what was copied. So I have a file open in Split view, I click on an
    image in the Design view... tool highlights the html in Code View,
    I right click and copy, then Ctl-F to bring up Find/Replace. When I
    try to paste, it brings up a pop-up window about Image Description-
    Alt text (I had copied an img src statement that didn't have any
    alt text) rather than doing a paste of the text I had copied. I am
    getting to paste via the Edit menu option since right click doesn't
    give me an enabled paste option to choose. I'm sure this is due to
    'user error' but can't figure what I'm doing wrong since I am
    following the steps described in the training manual. Thanks for
    any suggestions!

    Use Regular Expressions
    "Big_Slick" <[email protected]> wrote in
    message
    news:f0ip6t$ee8$[email protected]..
    >I need to know how to Find/Replace for more than one tag
    at a time
    >(I.E--Search
    > for <table>, <tr>, and <td> or
    and and remove the code) As it is
    > right
    > now, it will only search for one tag at a time but I
    would assume DW can
    > handle
    > this kind of thing.
    >
    > Thanks in advance.
    >

  • Stop Find/Replace syncing between different apps

    Hi all,
    I was wondering if there was any way to stop the Find/Replace function in some apps from syncing their search terms between each other.
    My problem:
    = Lets say I have Pages and TextEdit open and search for "tree" in Pages.
    = When I go over to TextEdit and do a command+F, the search window will automatically have the word "tree" populated in the search term field.
    = When I search for "shrub" in TextEdit and go back to Pages, the search term field in Pages gets filled in with "shrub" even though I still wanted to continue my search on "tree."
    So far I've seen this happen between any combination of Pages, TextEdit, Numbers, and Safari. Is there any way that I can stop these apps from syncing their search terms between each other?
    Thank you very much in advance.
    Hipsig

    It behave the same in 10.4.11.
    The Search / Replace dialog used by every app is based on a tool delivered by Apple in the resources which apps may use so, an entry made in the dialog of apply A appear in the dialog of appli B. It may appear in more.
    Look at these screenshots.
    The first three share the same string to search.
    They are from apps designed as word processor.
    The two other share an other value.
    They are from apps designed for developers.
    It show us that there are two sets of tools used for the Search / Replace feature, both of them sharing datas between the applications.
    Maybe this feature may be used for interesting things.
    In the operating system, we have only one clipboard but thanks to the described feature, we may pass three strings between two operations with a single switch task.
    It suffice
    to fill the Search field,
    to fill the Replace field
    to fill the clipboard
    from the source document.
    Then in the target document,
    paste the clipboard in the target doc,
    grab the content of the Replace field an paste it in the target doc
    grab the content of the Search field and paste in the target document.
    So, what you describes as anannoying feature which end users like me and you can't change, may be described as an interesting and useful feature.
    Just a matter of point of view (or of philosophy : I see the positive side, you see the negative one).
    Yvan KOENIG (VALLAURIS, France) lundi 5 juillet 2010 22:47:16

  • Batch code for running a find/replace all on multiple files within a source floder/directory

    What I need is a Batch source code that will open all files in a folder/directory and run a find and replace_all query within them and then save all the files.  The files were created in Illustrator and saved using the Scene7 FXG format extension.    These files will be uploaded into Scene7 as a group after the find and replace macro/query is run on the code.  The same find and replace query will be the same for all the files.  Basically this function or batch process  will save time in setting the same parameters all at one time instead of having to set the parameters individually in scene7.
    a source code sample of the find/replace module macro might be              searchString:  s7:colorvalue="#FFFFFFFF" 
                                                                                                                          replaceString: s7:colorValue="#&txtclr;"
                                                                                                                          searchWhat   "FXG document"    
                                                                                                                             searchSource:  true,
                                                                                                                        useRegularExpressions:   true
    I have no problems creating batch files within Ai and PhotoShop but I have limited programming skills in how to create source code for manuipulating documents outside of those apps or in a OS invironment.
    I could probably come up witha simple program to do what i want for one document but i get lost when dealing with multiple documents in a source folder (prolbem is,  I will be dealing with thousands of documents not 100 or less)
    If anything which Adope cloud app would work best:  Dreamweaver or Edge code   (or just use my notepad)

    What I need is a Batch source code that will open all files in a folder/directory and run a find and replace_all query within them and then save all the files.  The files were created in Illustrator and saved using the Scene7 FXG format extension.    These files will be uploaded into Scene7 as a group after the find and replace macro/query is run on the code.  The same find and replace query will be the same for all the files.  Basically this function or batch process  will save time in setting the same parameters all at one time instead of having to set the parameters individually in scene7.
    a source code sample of the find/replace module macro might be              searchString:  s7:colorvalue="#FFFFFFFF" 
                                                                                                                          replaceString: s7:colorValue="#&txtclr;"
                                                                                                                          searchWhat   "FXG document"    
                                                                                                                             searchSource:  true,
                                                                                                                        useRegularExpressions:   true
    I have no problems creating batch files within Ai and PhotoShop but I have limited programming skills in how to create source code for manuipulating documents outside of those apps or in a OS invironment.
    I could probably come up witha simple program to do what i want for one document but i get lost when dealing with multiple documents in a source folder (prolbem is,  I will be dealing with thousands of documents not 100 or less)
    If anything which Adope cloud app would work best:  Dreamweaver or Edge code   (or just use my notepad)

  • 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

  • MS Word crashes when I do find/replace with the OS X 10.5.6

    Does anyone know what I can do about MS Word crashing when I do a find and/or replace in a document? It happens constantly. The interesting thing is that is doesn't occur every single time I do find/replace but the SECOND time I use the feature. The only way I can manage to avoid the crash is to do find/replace, then exit out of the dialog box, and then open it up again. If I do a find/replace once and then continue using the same dialog box, Word crashes. Also, find/replace doesn't work most of the time.
    This never happened when I was using Word with my older OS.
    Help, please!!!
    Many thanks.

    Hmm...what about deleting the MS Word preferences? Does excel crash as well when doing the same function?
    To delete the preference put this in spotlight:
    com.microsoft.Word.plist
    Move it to the desktop, restart and see if the problem persists.
    It might be another preference that is the source of the problem.

  • FInd Feature with scanned documents

    Hope someone can help. I have some documents that I am trying to scan so I can find specific numbers on the documents. I am scanning using a CanoSacan Lide 100 and it is capable of scanning in OCR and PDF files. Once the documents are scanned and I open up Adobe reader, the find feature cannot find the numerical text I am trying to locate. I have read that the find feature does not work on scanned images so how can I get this to work? Funny thing, when I scanned my test document, saved it and used the find feature the first time it worked - now I am having no luck.
    Also, I came across a document referring to Adobe Acrobat 5 and picture capture. Does Adode reader have this feature - can't seem to find it.
    Thanks for any help you give me.

    Hi
    Finally figured it out...I am doing my happy dance as I type. The problem appears to be that the document must be scanned as a TEXT OCR file FIRST then converted to a PDF file. The scanner cannot do both actions at the same time. So I scanned the document as a TEXT OCR file type and then went to the scanner menu and selected save as PDF. Once that is done, I switched to Adobe Reader and opened my file. Word of caution, if the text is too crooked, the FIND feature will not work accurately.
    Hope this helps someone else who is trying to use scanned items and the FIND feature.
    Thanks for trying to help.

  • How can I remove all content between two tags using Find/Replace regular expressions?

    This one is driving me bonkers...  I'm relatively new to regular expressions, but I'm trying to get Dreamweaver to remove all content between two tags in an XML document.  For example, let's say I have the following XML:
    <custom>
    <![CDATA[<p>Some text</p>
    <p>Some more text</p>]]>
    </custom>
    I'd like to do a Find/Replace that produces:
    <custom>
    </custom>
    In essence, I'd like to strip all of the content between two tags.  Ideally, I'd like to know how to strip the CDATA content as well, to return the following:
    <custom>
    <![CDATA[]]>
    </custom>
    I'd much appreciate any suggestions on accomplishing this.
    Many thanks!

    Thanks much for your response.  I found David's article to be a little thin with respect to examples using quantifiers in coordination with the wildcard metacharacters; however, I was able to cobble together a working expression through trial and error using the information he presented.  For posterity, here’s the solution:
    Find:
    <custom>[\d\D]*?</custom>
    Replace:
    <custom>
    <![CDATA[]]>
    </custom>
    I believe this literally translates to:
    [] = find anything in this range/character class
    \d = find any digit character (i.e. any number)
    \D = find any non-digit character (i.e. anything except numbers)
    *? = match zero or more times, but as few times as possible (i.e. match multiple characters per instance, but only match one instance at a time, or none at all)
    I’m still not sure how to effectively utilize the . wildcard.  For example, the following expression will not find content that ends with a number:
    <custom>.*?[\D]*?</ custom >
    I'm presuming this is because numbers aren't included in the \D metacharacter; however, shouldn't numbers be picked up by the .*? expression?

Maybe you are looking for