Learn how to use wildcards and regular expressions to find and delete all text except for what’s in brackets in Microsoft Word.
If you have a Word document that contains text between brackets, such as citations, references, or annotations, you may want to delete all the other text and keep only the text in brackets. This can be useful for various purposes, such as extracting data, simplifying the document, or creating a list of sources. In this article, we will show you how to use wildcards and regular expressions to find and delete all text except for what’s in brackets in Microsoft Word.
Table of Contents
What are Brackets and How to Use Them in Word
Brackets are punctuation marks that are used to enclose additional information or clarifications within a text. There are different types of brackets, such as parentheses ( ), square brackets [ ], curly brackets { }, and angle brackets < >. Each type of bracket has its own function and usage, but in general, brackets are used to separate text that is not essential to the main message or argument of the document.
In Microsoft Word, you can insert brackets by using the keyboard shortcuts or the symbols menu. To insert parentheses, press Ctrl + 9 for the left parenthesis and Ctrl + 0 for the right parenthesis. To insert square brackets, press Ctrl + Alt + [ for the left bracket and Ctrl + Alt + ] for the right bracket. To insert curly brackets, press Ctrl + Alt + Shift + { for the left brace and Ctrl + Alt + Shift + } for the right brace. To insert angle brackets, press Alt + 60 for the less than sign and Alt + 62 for the greater than sign.
You can also insert brackets by clicking on the Insert tab, then clicking on the Symbol button, and choosing the bracket type from the drop-down menu. Alternatively, you can click on the More Symbols option and select the bracket type from the Symbol dialog box.
What are Wildcards and How to Use Them in Word
Wildcards are special characters that can be used to find and replace text patterns in Word. Wildcards can match any character, such as a letter, a number, a space, or a punctuation mark. Wildcards can also match specific types of characters, such as vowels, consonants, digits, or symbols. Wildcards can also be used to define groups of characters, repetitions, ranges, or alternatives.
To use wildcards in Word, you need to enable the Use wildcards option in the Find and Replace dialog box. To open the Find and Replace dialog box, press Ctrl + H or click on the Home tab, then click on the Replace button. In the dialog box, click on the More button, then check the Use wildcards box.
Some of the common wildcards that you can use in Word are:
- ? : matches any single character
-
- : matches any sequence of characters
- [ ] : matches any single character within the brackets
- [! ] : matches any single character not within the brackets
- ^ : matches the beginning of a paragraph
- $ : matches the end of a paragraph
- { } : defines a group of characters
- {n} : matches exactly n occurrences of the previous character or group
- {n,} : matches at least n occurrences of the previous character or group
- {n,m} : matches between n and m occurrences of the previous character or group
- @ : matches one or more occurrences of the previous character or group
- [a-z] : matches any lowercase letter from a to z
- [A-Z] : matches any uppercase letter from A to Z
- [0-9] : matches any digit from 0 to 9
- < : matches the beginning of a word
-
: matches the end of a word
For example, if you want to find all the words that start with a vowel and end with a consonant, you can use the wildcard expression <[aeiou][a-z]*[!aeiou]>.
How to Delete All Text Except for What’s in Brackets in Word
To delete all text except for what’s in brackets in Word, you can use the following steps:
- Open the Find and Replace dialog box by pressing Ctrl + H or clicking on the Home tab, then clicking on the Replace button.
- Click on the More button, then check the Use wildcards box.
- In the Find what box, enter the wildcard expression [^\]]+ (\ [|$) . This expression matches any sequence of characters that are not brackets, followed by either a bracket or the end of the paragraph.
- In the Replace with box, enter \1 . This expression replaces the matched text with the first capture group, which is the bracket or the end of the paragraph.
- Click on the Replace All button to delete all text except for what’s in brackets.
Alternatively, you can use the following steps:
- Open the Find and Replace dialog box by pressing Ctrl + H or clicking on the Home tab, then clicking on the Replace button.
- Click on the More button, then check the Use wildcards box.
- In the Find what box, enter the wildcard expression [^\ []* (\ [.?\]) [^\ [] . This expression matches any sequence of characters that are not brackets, followed by a bracketed text, followed by another sequence of characters that are not brackets.
- In the Replace with box, enter $1 . This expression replaces the matched text with the second capture group, which is the bracketed text.
- Click on the Replace All button to delete all text except for what’s in brackets.
Frequently Asked Questions (FAQs)
Question: How to delete all text except for what’s in parentheses in Word?
Answer: To delete all text except for what’s in parentheses in Word, you can use the same steps as above, but replace the brackets [ ] with parentheses ( ) in the wildcard expressions. For example, you can use the expression [^\)]+ (\ (|$) to find any sequence of characters that are not parentheses, followed by either a parenthesis or the end of the paragraph, and replace it with \1 to keep only the parenthesis or the end of the paragraph.
Question: How to delete all text except for what’s in curly brackets in Word?
Answer: To delete all text except for what’s in curly brackets in Word, you can use the same steps as above, but replace the brackets [ ] with curly brackets { } in the wildcard expressions. For example, you can use the expression [^\}]+ (\ {|$) to find any sequence of characters that are not curly brackets, followed by either a curly bracket or the end of the paragraph, and replace it with \1 to keep only the curly bracket or the end of the paragraph.
Question: How to delete all text except for what’s in angle brackets in Word?
Answer: To delete all text except for what’s in angle brackets in Word, you can use the same steps as above, but replace the brackets [ ] with angle brackets < > in the wildcard expressions. For example, you can use the expression [^\>]+ (\ <|$) to find any sequence of characters that are not angle brackets, followed by either an angle bracket or the end of the paragraph, and replace it with \1 to keep only the angle bracket or the end of the paragraph.
Summary
In this article, we have learned how to use wildcards and regular expressions to find and delete all text except for what’s in brackets in Microsoft Word. We have also learned how to use different types of brackets, such as parentheses, curly brackets, and angle brackets, and how to insert them in Word. We have also answered some frequently asked questions related to the topic.
Disclaimer: This article is for informational purposes only and does not constitute professional advice. The information and instructions provided in this article are based on the current version of Microsoft Word as of the date of publication. The results may vary depending on the version of Word, the operating system, and the document settings. The author and the publisher are not liable for any damages or losses that may arise from the use of the information or instructions in this article. The user is responsible for verifying the accuracy and suitability of the information or instructions before applying them to their own documents. The user is also responsible for backing up their documents before making any changes.