Swap the sequence of words, Change multiple periods to ellipses, Make sure your spaces follow the punctuation – Nisus Writer Pro User Manual

Page 344: Powerfind to use, Specified characters, Marks

Advertising
background image

324

Using PowerFind Pro

Finding and Replacing Text

Word

Any combination of alphanumeric characters (from as few as one character to
extremely long strings) surrounded by non-alphanumeric characters.

Advanced exercises, or more examples of putting PowerFind to use

These examples explain useful expressions in PowerFind Pro. You can use them as helpful tools for
preparing documents as well as for developing more complex user-defined expressions.

Swap the sequence of words

Swap any two consecutive words even if they are separated by a Return or a tab, use the Find
expression (\m\w+\M)(\s+)(\m\w+\M) and Replace expression \3\2\1. In this example, “report
status” replaces “status report.” Here’s what the characters mean

Character

What it Means

(\m\w+\M)

Finds a whole word (as defined above)

(\s+)

Finds any sequence of blank characters such as spaces, tabs, or Returns

\3

Represents the third parenthesized expression which is the second of the two
words found

\2

Finds whatever the second parenthesized expression (\s+) matches

\1

Finds the first parenthesized expression which is the first of the two words

Find any and/or all words that begin and end with specified characters

You can find any or all words that begin and end with characters you specify. For example all words
that share the same prefix and suffix (such as “preparation” and “prestidigitation”). The example
\m(a)([^\s]*)(d)\M finds every word that begins with “a” and ends with “d” from “ad” through “and”
to “ampersand.”

Character

What it Means

( and )

Expression delimiters, useful if you later want to manipulate the three segments of
the words

\m

Finds the beginning of a word

a

Not a metacharacter, but here it represents the character or string of characters
that must appear at the beginning of the word

[^\s]*

Finds any string of characters that is not a space (the middle of the word which
doesn’t even need to exist)

d

Not a metacharacter, but here it represents the character or string of characters
that must appear at the end of the word

Change multiple periods to ellipses

The following expressions find a sequences of two or more periods that follow an alphabetic or a
space and replaces them with an ellipsis “…”.

1. In the Find what text box enter: ([[:alpha:]]\s)(\.\.+)
2. In the Replace with text box enter: \1…

It then removes a space preceding any ellipsis.

3. In the Find what text box enter: (\s)(…)
4. In the Replace with text box enter: \2

Make sure your spaces follow the punctuation

Fast typists frequently press the Space Bar before typing their punctuation. The next expression
finds one or more spaces that precede any punctuation and places them after the punctuation.

1. In the Find what text box enter: (\s)([[:punct:]])
2. In the Replace with text box enter: \2\1

Make sure your punctuation appears inside quotation marks

Common American practice is to have commas and periods appear inside of quotation marks. The
following expression finds these punctuation marks that appear outside quotes and places them
inside the quotes.

1. In the Find what text box enter: (”)(\.|,)
2. In the Replace with text box enter: \2\1

If you want all punctuation to appear inside quotation marks use this expression

1. In the Find what text box enter: (”)[[:punct:]]
2. In the Replace with text box enter: \2\1

Advertising