Results 1 to 9 of 9

Thread: Selection.Find

  1. #1
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Selection.Find

    I want to search thru a document for every occurrence of any number of letters between backets. Like this:

    {word_one} {sentence_one} {word_two}

    Is there a wildcard or something for the .text property that will do this?
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  2. #2
    2 Star Lounger
    Join Date
    Mar 2001
    Location
    Oregon, USA
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Selection.Find

    Hi Kevin,

    As far as I know, brackets are reserved characters when you use wildcards. Does it have to be just letters (I notice you include underscores)? If it can be any sequence of characters between brackets, how about the kludge that follows?

    1) Replace all open and close brackets with something discrete like zzzz and yyyy.

    2) Set .MatchWildcards to true and .Text to "zzzz*yyyy". Do your searches.

    3) Replace zzzz and yyyy back to brackets.

    HTH,

    Chris

  3. #3
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Selection.Find

    Chris,

    Thanks for posting. I suppose I could change the {} to [] or something else that's not a reserved character.

    Your idea is a good one if I can't get a better solution.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Selection.Find

    I think the problem is that square brackets and braces, or curly brackets, have specific meanings in searches. Square brackets usually indicate literals, and curly brackets are used in some kinds of SQL statements, so it's best to just avoid them and find a substitute as Chris has suggested.
    Charlotte

  5. #5
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Selection.Find

    Kevin,

    Another thing to look out for (if you are doing something like highlighting all text within brackets) is nested sets of brackets, as well as instances of open brackets that are missing their close brackets counterparts.

    Robin Trew posted some typically challenging code for searching for these some time ago on the old Lounge; I'll look to see if I have a hard copy and repost if found and it looks useful.

    Gary

  6. #6
    Xiao Bin
    Guest

    Re: Selection.Find

    For the simplest case, in which there is no nesting of brackets, you could choose MoreUse Wilcards in the Word Find dialog, and then search for the wildcard pattern:
    <pre>{[!}]{1,}}</pre>


    The backslash allows you to search for characters which have a special meaning in the wildcard language. The pattern above means something like "an opening bracket, followed by one or more characters which are not closing brackets, followed by a closing bracket.

  7. #7
    2 Star Lounger
    Join Date
    Mar 2001
    Location
    Oregon, USA
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Selection.Find

    Xiao Bin,

    *Very* cool. That's a new one in the toolbag.

    Thanks.

  8. #8
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Selection.Find

    Xiao,

    That's a nice one. Very nice. Where, may I ask did you find this bit of forgotten lore?

    I modified your suggestion to {*} and get the results I need.

    Thank you.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  9. #9
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Selection.Find

    Gary,

    Check out Xiao's post below -- just what I was looking for. No need to dig up Robin's code -- unless you really want to. I really enjoyed reading Robin's posts, so seeing one again would be great.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

Posting Permissions

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