Search with a pattern
- Open the Find and replace panel with Ctrl+F.
- Check Pattern.
- Type a regular expression in Find, for example
\d+for any number. - Choose Next to step through the matches, or type in Replace with and choose Replace or Replace all.
- Patterns use the .NET regular expression rules. Match case and Whole words still apply.
- In Replace with,
$1puts back the first part of the match in brackets,$2the second, and$0the whole match. - A match stays inside one paragraph. A replacement cannot split a paragraph:
\nand\tare kept as typed. - If the pattern has a mistake, the panel says "The pattern is not valid" with the reason. A pattern that would match empty text is refused: add something it must find.
Save a find
- Fill in the Find and replace panel the way you want it, including Replace with and the checkboxes.
- Choose Edit then Saved finds and patterns….
- Choose Save the current find….
- Type a name and choose OK.
A saved find keeps the find text, the replacement and the Pattern, Match case and Whole words settings. Saving under a name you already used replaces the old one. Saved finds belong to your Windows user, so they are offered in every book.
Run a saved find
- Choose Edit then Saved finds and patterns….
- Pick a find. The Find and replace panel opens with everything filled in.
- Choose Next, Replace or Replace all as usual.
To delete one, choose Remove a saved find… in the same list, then pick the find.
Built-in examples
The list also offers six patterns, marked "example":
| Example | Finds | Replaces with |
|---|---|---|
| Double spaces | Two or more spaces in a row. | One space. |
| Space before punctuation | Spaces before a comma, period, semicolon, colon, exclamation mark or question mark. | The punctuation without the space. |
| Repeated word | The same word twice in a row. | The word once. |
| Three dots to an ellipsis | Three typed periods. | One ellipsis character. |
| Two hyphens to an em dash | Two hyphens, with any spaces around them. | An em dash with no spaces. |
| Words in capitals | Words of three or more capital letters. | Nothing: use Next to review them, not Replace all. |
Replace all is one step: press Ctrl+Z to undo every replacement at once.
Related
- Find and replace text in the whole book
- Jump to headings, breaks, pictures and notes
- Check readability, word use, dialogue and style
Still stuck?
Choose Help then Report a problem… in LeafBound to send us the details, or write to support.