• Wildcards search excluding a specified character (Word97)

    Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » Wildcards search excluding a specified character (Word97)

    Author
    Topic
    #423320

    Hi

    Using a Word wildcard search, is it possible to specify a find text that excludes any occurrence of a specified character?

    For example, let’s say the document contains the following text: “XabcdXefghX”, and I want to find all strings starting and ending with X, but not including b. Searching for “X*X” nearly does it, but finds “XabcdX” (which I don’t want, because it contains a “b”) as well as “XefghX”.

    Can do?
    Dale

    Viewing 0 reply threads
    Author
    Replies
    • #968345

      I don’t have a copy of Word 97 handy, but here’s the wildcard (make sure “use wildcards” is checked) pattern for what you want:

      
      

      “” is “match X at the end of the word

      HTH.

      • #969619

        Thanks, Andrew. Quite powerful, isn’t it. Reminds me of conversion mechanism that was used by Folio Views.

        Is it possible to exclude a string? For example, let’s say the document contains the following text: “XyyybcyyyXyyycbyyyX”, and I want to find all strings starting and ending with X, but not including the string “bc” (that is, I want to find “XyyycbyyyX”, but not “XyyybcyyyX”).

        Thanks for your help
        Dale

        • #969706

          Hi Dale,

          Word’s wildcards are more powerful than most people realize, but they’re still rather limited. That kind of match is a bit more than it can handle on its own. The best you could probably do natively is to use some VBA to examine the matches to the original pattern to see if they include the substring, then act based on that.

          Complex pattern matching in strings is not an uncommon task, and there are many tools far better suited for it than Word. You’re even further limited by still using Word 97. With Word 2000 and up, you have access to the VBScript RegExp object, which gives you access to a full Regular Expression (string-pattern matching) engine:
          http://www.windowsdevcenter.com/pub/a/wind…dex.html?page=4%5B/url%5D

          Generally, when complex patterns like this come up, I turn to other tools like Perl or Ruby:
          http://www.perl.com/pub/a/2005/05/26/word_control.html%5B/url%5D

    Viewing 0 reply threads
    Reply To: Wildcards search excluding a specified character (Word97)

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

    Your information: