• Find/Replace

    Author
    Topic
    #472241

    Is there a code in MS Word’s Find and Replace dialogue for “p(no.)(no.). “, where (no.) is any digit from 0-9? I’d like to replace that with “^l(no.)(no.). “

    Viewing 4 reply threads
    Author
    Replies
    • #1249030

      Is there a code in MS Word’s Find and Replace dialogue for “p(no.)(no.). “, where (no.) is any digit from 0-9? I’d like to replace that with “^l(no.)(no.). “

      I’m going to assume that first p is a paragraph break. Please edit my code if that is not the case.

      It’s easy to do the find part using

      Code:
      Find what: ^p^#^#.

      But replacing is more tricky. In order to replace a portion of the found text and preserve the rest, you need to enable wildcards. But then ^p and ^# are no longer legal in the find what string. So that requires you to use a different syntax that is closely similar in effect but not identical (^13 picks up UNIX-style line breaks as well as Windows style line breaks):

      Code:
      Find what: ^13([0-9]{2}.)
      Replace with: ^l1

      Note: the 1 copies the text match from the first parenthetical in the find what expression.

      Edit: to match and replace a trailing space, add that after the period.

    • #1249730

      I have a document with the Arabic word for “article” followed by an article number appearing over two hunderd times. I want to put a hard paragraph mark (enter; line break; ^p) between the article, the article number, and the text of teh article that follows so that the text of the article that follows will be below the word “article” and the corresponding article number.

      I enabled wildcards adn used this code:
      Find: {(2)} المادة
      Replace: 1^p

      When I attempt a search, I get this message: “The Find What text contains a Pattern Match expression which is not valid.”

      What’s not valid about it? And anyway, what does {(2)} mean? Whenever I search for that, I get any single character or space, regardign of whether there is a 2 in the parentheses or any other number, including 10.

    • #1249739

      Hi jmt,

      What’s the actual string preceding the ‘المادة’ that you’re searching for? Your find code certainly won’t work as a wildcard Find expression – the {(2)} isn’t a valid expression. Assuming you’re looking for ‘(#) المادة’, where the # is a 1-3 digit number, try using:
      Find = ‘(([0-9]{1,3}) )?????? ‘
      Replace = ‘1’
      (without the single quotes)

      Cheers,
      Paul Edstein
      [Fmr MS MVP - Word]

    • #1250430

      I am now trying to take every reference in my document to “(no.) المادة”, where (no.) is any number from 1 – 999, and replace it with “^p(no.) المادة”, such that before the number (after the number if you’re thinking linearly right to left as in Arabic) there will be a hard line break.

      I was going to first go after the two digit numbers and then focus on the three digit numbers and then the one digit numbers. So focusing on the two digit numbers, I tried:
      Find: ({2}[0-9]) المادة
      Replace with: 1^p

      However, Word was replacing the selection with just the number followed by a hard enter instead of the word المادة followed by the number followed by a hard enter. Is Word unable to replicate the Arabic word using wildcards?

      Also, macropod, for some reason, I’m still getting a message that the search item I’m looking for was not found when I search for (([0-9]{1,3}) )??????

      I’m just going to attach the document. Please note that I already inserted hard paragraph breaks (^p) into the first few articles, but around article 26 (المادة 26) there is no hard paragraph break after the article number. If anyone could figure out the exact code that would work, it would be great, especially if it is a single code that coudl be used for one, two, or three digit numbers.

    • #1250438

      Hi jmt,

      I’m not surprised the Find didn’t work, since the numbers aren’t enclosed in parentheses, which is what my Find code was based on. As I said:

      Assuming you’re looking for ‘(#) المادة’ …

      . Your post was quite ambiguous as to what you were looking for.

      For your purposes, you should be able to use a wildcard Find/Replace, with:
      Find = (المادة )([0-9]{1,3})
      Replace = 21^p

      Finally, I see you’ve been posting on the same topic at: http://www.eileenslounge.com/viewtopic.php?f=26&t=3910
      For cross-posting etiquette, please see: http://www.excelguru.ca/node/7

      Cheers,
      Paul Edstein
      [Fmr MS MVP - Word]

    Viewing 4 reply threads
    Reply To: Find/Replace

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: