Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    3 Star Lounger
    Join Date
    Dec 2009
    Location
    West Midlands, UK
    Posts
    236
    Thanks
    233
    Thanked 2 Times in 2 Posts

    Find/Replace in Word

    I often copy extracts from Wikipedia articles, but find removing the [EDIT] and [59] reference indicators tedious. I can remove the square brackets in find/replace in Word, but is there a way of removing all of these reference indicators in one go.

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Mike,

    Yes you can using Advanced F&R w/Wild Cards and Regular Expressions. Could you post a sample document for us to figure out the Regular Expression required?

    HTH
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  3. The Following User Says Thank You to RetiredGeek For This Useful Post:

    mike21 (2016-01-11)

  4. #3
    3 Star Lounger
    Join Date
    Dec 2009
    Location
    West Midlands, UK
    Posts
    236
    Thanks
    233
    Thanked 2 Times in 2 Posts
    Sample

    Alzheimer's disease[edit]

    Brain atrophy in severe Alzheimer's
    Alzheimer's disease accounts for up to 50% to 70% of cases of dementia.[2][3] The most common symptoms of Alzheimer's disease are short-term memory loss and word-finding difficulties. People with Alzheimer's also have trouble with visual-spatial areas (for example they may begin to get lost often), reasoning, judgment, and insight. Insight refers to whether or not the person realizes he/she has memory problems.
    Common early symptoms of Alzheimer's include repetition, getting lost, difficulties keeping track of bills, problems with cooking especially new or complicated meals, forgetting to take medication, and word-finding problems.
    The part of the brain most affected by Alzheimer's is the hippocampus. Other parts of the brain that show shrinking (atrophy) include the temporal and parietal lobes.[4] Although this pattern suggests Alzheimer's, the brain shrinkage in Alzheimer's disease is very variable, and a scan of the brain cannot actually make the diagnosis. The relationship between undergoing anesthesia and AD is unclear.[28]

  5. #4
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Mike,

    1. OK, open up Find & Replace Ctrl+H
    2. Setup options as shown below:
      Mile21.PNG
    3. In the Find what:
      To replace [nnn] use: \[[1-9]{1,}\]
      To replace [edit] use: \[edit\]
    4. Leave Replace with: BLANK!
    5. Click the Replace All


    Of course you'll test this on a COPY of one of your documents!!!!!

    HTH
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  6. The Following User Says Thank You to RetiredGeek For This Useful Post:

    mike21 (2016-01-12)

  7. #5
    5 Star Lounger Lugh's Avatar
    Join Date
    Jun 2010
    Location
    Indy
    Posts
    619
    Thanks
    166
    Thanked 76 Times in 67 Posts
    Quote Originally Posted by RetiredGeek View Post
    To replace [nnn] use: \[[1-9]{1,}\]
    To replace [edit] use: \[edit\]
    RG, if you would indulge my VBA novice curiosity

    Why wouldn't \[*\] do for replace? [obviously assuming there's no wanted material between the square brackets in the articles, which is the case in the example]
    Lugh.
    ~
    Windows 10 Pro x64 1607; Office 2016 (365 Home) x32; Win Defender, MBAM Pro

    ASRock H97 Anniversary; Xeon E3-1231V3 (like i7)
    Gigabyte GeForce GTX 970; 12GB Crucial DDR3 1600
    Logitech MX Master mouse; Roccat Isku kb

  8. The Following User Says Thank You to Lugh For This Useful Post:

    mike21 (2016-01-12)

  9. #6
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Lugh,

    It would if there was no other use of square brackets anywhere in the documents being worked on. However, I don't know that to be the case, given the limited example and information provided by the OP, and for safety sake I made it specific to the OP's example and information.

    HTH
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  10. The Following 2 Users Say Thank You to RetiredGeek For This Useful Post:

    Leslie.Williams (2016-01-15),mike21 (2016-01-12)

  11. #7
    3 Star Lounger
    Join Date
    Dec 2009
    Location
    West Midlands, UK
    Posts
    236
    Thanks
    233
    Thanked 2 Times in 2 Posts
    Thank you both. The first, more elaborate, suggestions worked fine, the one string removing all the reference numbers and their brackets, and the second removing the edit. For interest I tried the second - it removed the edit but only the references with just one digit, it left the rest untouched, I then tried it with **, but it still only removed the ones with one digit. I have copied the procedure to a file which is now stored in several folders, to make sure I find it when required.

  12. #8
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,172
    Thanks
    47
    Thanked 981 Times in 911 Posts
    Try this:
    \[.*\]
    Should find bracket, any character any number of times, bracket.

    cheers, Paul

  13. The Following User Says Thank You to Paul T For This Useful Post:

    mike21 (2016-01-13)

  14. #9
    5 Star Lounger Lugh's Avatar
    Join Date
    Jun 2010
    Location
    Indy
    Posts
    619
    Thanks
    166
    Thanked 76 Times in 67 Posts
    Quote Originally Posted by mike21 View Post
    ...only the references with just one digit, it left the rest untouched, I then tried it with **, but it still only removed the ones with one digit.
    Quote Originally Posted by Paul T View Post
    \[.*\]
    Should find bracket, any character any number of times, bracket.
    Hmm, I'm puzzled. This Office.com article lists the codes for use with wildcards. The entry for the asterisk says...
    "Any string of characters, including space and punctuation characters
    *
    s*d finds sad, started, and significantly altered."
    ...so I can't see why it only picked up one character for mike21--that's the behavior of the ? wildcard.

    Paul, the dot you use isn't listed in that article. Is there a more complete list of wildcard codes somewhere else?

    Thanks,
    Lugh.
    ~
    Windows 10 Pro x64 1607; Office 2016 (365 Home) x32; Win Defender, MBAM Pro

    ASRock H97 Anniversary; Xeon E3-1231V3 (like i7)
    Gigabyte GeForce GTX 970; 12GB Crucial DDR3 1600
    Logitech MX Master mouse; Roccat Isku kb

  15. The Following User Says Thank You to Lugh For This Useful Post:

    mike21 (2016-01-13)

  16. #10
    3 Star Lounger
    Join Date
    Dec 2009
    Location
    West Midlands, UK
    Posts
    236
    Thanks
    233
    Thanked 2 Times in 2 Posts
    It found the four characters of "edit" but not two numbers - i tried it several times but with the same result - worked with one number but not two.

  17. #11
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Quote Originally Posted by RetiredGeek View Post
    To replace [nnn] use: \[[1-9]{1,}\]
    To replace [edit] use: \[edit\]
    What about 0s in [nnn] and [EDIT]???

    Mike21: Does the content you want to delete appear as hyperlinks, or as plain text? If it's plain text, a wildcard Find/Replace with:
    Find = \[[0-9A-Za-z ]{1,}\]
    Replace = nothing
    should delete them all. If they're hyperlinks, you could use a macro like:
    Code:
    Sub Demo()
    With ActiveDocument
      While .Hyperlinks.Count > 0
        .Hyperlinks(1).Delete
      Wend
    End With
    End Sub
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  18. #12
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,172
    Thanks
    47
    Thanked 981 Times in 911 Posts
    Quote Originally Posted by Lugh View Post
    Paul, the dot you use isn't listed in that article. Is there a more complete list of wildcard codes somewhere else?
    Typically MS call it "regular expression" but use their own version. Just like the IE version of HTML.

    cheers, Paul

  19. #13
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Quote Originally Posted by Paul T View Post
    Quote Originally Posted by Lugh View Post
    Paul, the dot you use isn't listed in that article. Is there a more complete list of wildcard codes somewhere else?
    Typically MS call it "regular expression" but use their own version. Just like the IE version of HTML.
    The dot (period) has nothing to do with Word's wildcards - it's an error in your Find expression, which means Word would only find an opening square bracket followed by a period - then whatever else - before the closing square bracket, but that isn't what mike21 says his content contains. Nor does MS call it a "regular expression". While there are similarities - and MS has an extensive "regular expression" implementation, Word's wildcards have never pretended to be the same thing.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  20. #14
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,172
    Thanks
    47
    Thanked 981 Times in 911 Posts

  21. #15
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Regardless of what's in your link re the term 'regular expression', it was disingenuous of you to fob off your error with the period as:
    Quote Originally Posted by Paul T View Post
    Typically MS call it "regular expression" but use their own version.
    MS does nothing of the sort, as the same link clearly shows...
    Cheers,

    Paul Edstein
    [MS MVP - Word]

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •