Searching for Entities and Tags
You can include markup in the contents of the Search and Replace fields by selecting the Match Markup check box. This includes both entities and tags (elements). You use the ASCII representations of elements and entities when including them in a search. Character entities will be found when searched for regardless of whether they are displayed as characters or tags.
When using Match Markup:
• Use a beginning ampersand (&) and ending semicolon (;) when representing entities in searches. For instance, entering © in the Find What field finds occurrences of the copyright symbol (© ) in your document.
Entering Mine© in Find What finds “Mine©”.
• Because ampersand and semicolon are used as entity delimiters, to search specifically for an ampersand or semicolon you must precede it with a backslash (\). Enter \& in Find What to find an ampersand in your document. Enter \&© to find an ampersand followed by a copyright symbol.
• Another consideration for the ampersand (&) concerns the use of regular expressions in the Replace With field. The ampersand is a special character used in regular expressions. When used in the Replace With field, it represents the contents of the Find What field. For instance:
◦ The word “mathematics” in the Find What field
◦ And “complex &” in the Replace With field
◦ Results in the phrase “complex mathematics” replacing the word “mathematics” in your document
If there had also been an entity in the Replace With field, the entity would have to be preceded by a backslash (\). For instance:
◦ The word “mathematics” in the Find What field
◦ And “\©complex &” in the Replace With field
◦ Results in “©complex mathematics” replacing the word “mathematics” in your document
If you literally want an ampersand (&) as part of your replacement text, use the character entity for ampersand. For example:
◦ The word “mathematics” in the Find What field
◦ And “\&\copy;complex &” in the Replace With field
◦ Results in “&©complex mathematics” replacing the word “mathematics” in your document
This only works when there is markup in the Replace With field. When no entities or tags are part of the replacement text, use “\&”.
(This obviously is not a realistic example of the use of copyright and ampersand, but it illustrates the point well.)
• Begin tags are represented as <tagname>, where tagname is the name of the element.
End tags are represented as </tagname>, where tagname is the name of the element.
Entering <para>This is the end of the long search.</para> in Find What finds a paragraph, including tags, whose entire contents is the sentence shown.
• Searches and replacements can only be done on a balanced region of the document. You cannot replace just a begin tag and some text. You would have to replace the begin and end tag and their contents. No replacements are allowed which would cause a tag pair to be unbalanced or the document to be out of context.