12

I know little of wildcard usage in word.

wildcards - case sensitive

TO FIND

enter mark                       ^13
tab                              ^t
any lowercase letter             [a-z]
any uppercase letter             [A-Z]
any letter                       [A-z]
any digit                        [0-9]
any no. between 6–9              [6-9]
any letter between d–k           [d-k]
any word contains only letters   ([A-z]@>)
any word contains only digits    ([0-9]@>)
for grouping (for replace)       (   )
any character(s) between ...     (*)
any para                         ^13(*)^13

TO REPLACE

To replace first group   \1
To replace second group  \2
enter mark               ^p
tab                      ^t

I want to know more about this. Can anyone help me?

0

5 Answers 5

4

Adapted from this article

Search Operators:

? - Any Character. (regex equivalent: .)

Example: d?g finds dig, dog, and dug

[-] - Character in Range. (regex equivalent: same)

Example: [a-m]end finds bend, fend, lend, and mend (the first character in this case is a, m, or any letter between)

< - Beginning of Word. (regex equivalent: ^)

Example: <tele finds telemarketing, telephone, and television

> - End of Word. (regex equivalent: $)

Example: tion> finds aggravation, inspiration, and institution

() - Expression. (regex equivalent: (?:))

Example: Lets you "nest" search expressions within a search term. For instance, <(pre)*(ed)> to find presorted and prevented

[!] - Not. (regex equivalent: [^])

Example: Finds the text but excludes the characters inside the brackets; t[!ae]ll finds till and toll but not tall and tell

{n} - Num of Occurrences. (regex equivalent: same)

Example: Finds the specified number of occurrences of the letter immediately before the {; to{2} finds too and tool but not to

{n,} - Num of Occurrences. (regex equivalent: same)

Example: Adding a , after the number tells Word to look for at least that number of occurrences; a {4,} finds four or more of the letter a in a row

{n,n} - Num of Occurrences. (regex equivalent: same)

Example: 10{2,3} finds 100 and 1000 but not 10

@ - Previous 1 or More. (regex equivalent: +)

Example: Finds one or more of the character immediately preceding the @; ^p@^t finds one or more paragraph break marks followed by a tab mark

* - 0 or More Characters. (regex equivalent: .*)

Example: Finds a word with one or more of the specified character, or words with none of the characters; des*t finds descent, desert, dessert, and destruct

[] - One of the specified characters. (regex equivalent: same)

Example: b[aeiou]t finds bat, bet, bit, and but

[!a-z] - Any single character with the exception of the ones in the range inside the bracket. (regex equivalent: [^a-z])

Example: m[!o-z]st finds mast and mist but not most or must

0
1

This looks like a non-standard notation for regular expressions, frequently abbreviated as regex or regexp. This is a tremendously important tool to learn if you do any serious text processing. As you have already understood, regex allow for powerful pattern matching and substitution. The notation you provided resembles the standard greatly, so I could recognise it. There is an industry standard, POSIX, and a de-facto standard, Perl regex. The next paragraph is boring history, skip it if you want.

POSIX regex are used in many user-facing tools from POSIX-compliant operating systems (think Linux and its not-so-distant relatives). The canonical example is grep, which allows you to search for text in files. The text to match is specified in regex. Perl, a programming language, took the concept and extended it greatly for its purposes. Later a subset of this functionality was made it available as a code library, PCRE. All sorts of software embed this library, most notably text editors.

I can see a few differences to what I am used to in the notation above. Word's symbol for symbol for escape sequences is ^, normally it is \. »Only digits« is used often, so it has an abbreviation in Perl, namely \d is equivalent to the character class [0-9]; similarly, \w means word characters and is equivalent to [0-9a-zA-Z_]. Word's notation appears cumbersome against it. I do not know the other limitations of Word, so I encourage you to switch to a text editor with PCRE support.

You should learn first about whitespace matching (abbreviation \s) and repetition (+ and *). Perl's regex are explained in perlrequick, perlretut and perlre. To start experimenting right now, use the Flash based RegExr.

0

Wildcards are like the blank pieces in Scrabble, or like the Jokers you can use in some card games to stand in for any card. You are perhaps already familiar with the “” and “?” wildcards from file matching: In the File + Open dialog, you can display all files with the extension “.doc” by typing “.doc”, or all files “01062001.doc”, “01072001.doc”, “01122001.doc”... by typing “01??2001.doc”.

But the wildcard feature in Word goes way beyond that, and can be very powerful.

To begin, you must first turn Wildcards on in the Find/Replace dialog. To do so, bring up the Find dialog, click More and check Use wildcards. In a macro, set .Find.MatchWildcards = True. If you do not do this, Word treats the wildcard characters as if they were ordinary text.

As we'll see later, you can define ranges [], groups (), repeats @, {}, anchors < > and exceptions !. With these regular expressions you can search for patterns in your text that have certain things in common (some pattern: for example, that they only contain certain characters, or a certain number of characters).

Note: Word uses “lazy” pattern matching: this means it will quit matching as soon as possible. Most Unix tools use “greedy” pattern matching (the algorithm tries to match as much text as possible), so if you have used such tools, beware!

The secret of using wildcard searches is to use a “pattern” that identifies the string of text that you wish to find, and ignores everything else. Wildcards are used to represent the characters or sequences of characters in that string.

Because different combinations of characters can be represented by a variety of wildcard combinations, there is often more than one way of identifying a particular string of text within a document. How you choose to represent that group of characters is therefore often a matter of individual preference; and the context of the text within the document will to a great extent dictate the most suitable combination to use on a particular occasion.

The following is a list of the characters that have a special meaning in wildcard searches ( [ ] { } < > ( ) - @ ? ! * \ ).

Note: wildcard searches are case sensitive.

It doesn't help that the list of wildcard characters in Word's Help files is almost impossible to find! The wildcard characters are all listed and described in this article, but if you need to find them in Help, the topic is called: “Type wildcards for items you want to find”. But you can't get to that article directly; you must first find the topic: “Fine-tune a search by using wildcard characters”, which contains a link to it!

Zen tip: when using wildcard searches: don't wrinkle your brow or bite on your tongue while thinking it through – you have to keep up a regular expression. :-|

0

Word's wildcards are regular expressions, with expressiveness between the Bash shell's extended globbing and Perl's PCRE regexes.

Microsoft have two introductory articles, Add power to Word searches with regular expressions and Putting regular expressions to work in Word, that explains some of the main concepts.

Cf. also a question I asked, What is the easiest way to do PCRE-style regexp search/replace for MS Word?

0

I think Word wildcards are quite limited when it comes to searching and replacing text in Word documents. Normal regular expressions are much more reliable and there are numerous web resources and forums which will help in creating regular expressions and learning the syntax.

Recently, I developed a special tool that allows one to search and replace text in Word documents using .NET regular expressions. The tool is called Multiple Find & Replace tool and it is part of TransTools+ plug-in for Microsoft Word: http://www.translatortools.net/transtoolsplus-multiplereplace.html

For example, if you need to replace [b]text[/b] with "text" in bold formatting, you will need to use the following parameters.

1) Open Multiple Find & Replace tool

2) Add a new search and replace expression with the following parameters.

Mode: Regular expression

Find What: [[bB]](.+?)[/[bB]]

Replace With: $1

Apply specific formatting upon replacement: Bold - Yes

Screenshot: http://prntscr.com/nj01wb

Screenshot of Multiple Find and Replace pane after adding the search & replace expression: http://prntscr.com/nj0286

3) Click Replace All to perform replacements right away or click Find All to find all occurrences in order to decide what needs to be replaced.

Text before replacement: http://prntscr.com/nj02jc

Text after replacement: http://prntscr.com/nj02qh

You can find some examples of the tool's usage along with description of its features here: http://www.translatortools.net/news/transtoolsplus-v1-1.html

Stanislav

You must log in to answer this question.