(→Pattern Matching Codes) |
(→Related Resources) |
||
| (7 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
<seo title="Pattern Matching & Codes | vEdit" description="Pattern Matching makes it possible to search not just for particular characters, but also characters such as “any digit” or for characters that meet special conditions."></seo> | <seo title="Pattern Matching & Codes | vEdit" description="Pattern Matching makes it possible to search not just for particular characters, but also characters such as “any digit” or for characters that meet special conditions."></seo> | ||
| − | {{DISPLAYTITLE: | + | {{DISPLAYTITLE:Pattern Matching & Codes}} |
Pattern Matching makes it possible to search not only for particular characters, but also for types of characters such as “any digit” or for characters that meet special conditions such as "occurring at the beginning of a line”. | Pattern Matching makes it possible to search not only for particular characters, but also for types of characters such as “any digit” or for characters that meet special conditions such as "occurring at the beginning of a line”. | ||
| Line 6: | Line 6: | ||
These generalized searches are performed by using “pattern matching codes” within the search string. Each pattern matching code consists of the special character “|” followed by another character, typically a mnemonic letter. | These generalized searches are performed by using “pattern matching codes” within the search string. Each pattern matching code consists of the special character “|” followed by another character, typically a mnemonic letter. | ||
| − | <div class="callout note">“'''|'''” is the “pipe” character, which is <kbd>Shift-\</kbd> on the keyboard. All pattern matching codes begin with this character. | + | <div class="callout note">“'''|'''” is the “pipe” character, which is <kbd>Shift-\</kbd> on the keyboard. All pattern matching codes begin with this character. Although the mnemonic letter can be in upper or lower case, for purposes of clarity, all examples show these letters in uppercase. Most of the pattern matching codes only have a special meaning in the search string; they have no meaning in the replacement string. If you need “variable” characters in the replacement string, you must use [[Search_And_Replace#Regular_Expressions|regular expressions]].</div> |
| − | + | ||
| − | Although the mnemonic letter can be in upper or lower case, for purposes of clarity, all examples show these letters in uppercase. | + | |
| − | + | ||
| − | Most of the pattern matching codes only have a special meaning in the search string; they have no meaning in the replacement string. | + | |
| − | + | ||
| − | If you need “variable” characters in the replacement string, you must use [[Search_And_Replace#Regular_Expressions|regular expressions]]. | + | |
| − | </div> | + | |
===Examples of search strings using pattern matching=== | ===Examples of search strings using pattern matching=== | ||
| Line 51: | Line 44: | ||
:Match any (non-standard) control character other than Tab, Carriage-Return and Line-Feed. It is useful for finding stray control characters in a file. See also '''|C''' and '''|G'''. | :Match any (non-standard) control character other than Tab, Carriage-Return and Line-Feed. It is useful for finding stray control characters in a file. See also '''|C''' and '''|G'''. | ||
;|L | ;|L | ||
| − | :Match the “newline” character(s) Carriage-Return and/or Line-Feed depending upon the file type. With Windows/DOS files, the Carriage-Return is optional. | + | :Match the “newline” character(s) Carriage-Return and/or Line-Feed depending upon the file type. With Windows/DOS files, the Carriage-Return is optional. Also see '''|N''' and [[Pattern_Matching_Newline|Pattern Matching the Newline]]. |
;|M | ;|M | ||
:Match multiple characters - zero, one or more characters until the string following the '''|M''' is satisfied. Since the match may cover many lines, it may match a huge number of characters. Use '''|*''' instead, to match multiple characters on one line. This code is not generally not useful as the first item in a search string. See also '''|Y''' and the following sub-topic “Matching Multiple Characters”. | :Match multiple characters - zero, one or more characters until the string following the '''|M''' is satisfied. Since the match may cover many lines, it may match a huge number of characters. Use '''|*''' instead, to match multiple characters on one line. This code is not generally not useful as the first item in a search string. See also '''|Y''' and the following sub-topic “Matching Multiple Characters”. | ||
;|N | ;|N | ||
| − | :Match the “newline” Carriage-Return and/or Line-Feed depending upon the file type. With Windows/DOS files, the Carriage-Return is mandatory. This code can also be used in the replacement string. See also '''|L'''. | + | :Match the “newline” Carriage-Return and/or Line-Feed depending upon the file type. With Windows/DOS files, the Carriage-Return is mandatory. This code can also be used in the replacement string. See also '''|L''' and [[Pattern_Matching_Newline|Pattern Matching the Newline]]. |
;|Oooo | ;|Oooo | ||
:Match the character with octal value ‘ooo’. Three digits MUST be present. This code can also be used in the replacement string. | :Match the character with octal value ‘ooo’. Three digits MUST be present. This code can also be used in the replacement string. | ||
| Line 94: | Line 87: | ||
:Use the contents of text register ‘r’ in this position in the search string. This code can also be used in the replacement string. | :Use the contents of text register ‘r’ in this position in the search string. This code can also be used in the replacement string. | ||
;|{set} | ;|{set} | ||
| − | :Match any one item in the “pattern set”. | + | :Match any one item in the “pattern set”. [[Pattern_Matching_Sets|Learn more about Pattern Matching Sets.]] |
;|[set] | ;|[set] | ||
| − | :Match one optional occurrence of any item in the “pattern set”. This code is not meaningful as the first item in a search string. | + | :Match one optional occurrence of any item in the “pattern set”. This code is not meaningful as the first item in a search string. [[Pattern_Matching_Sets|Learn more about Pattern Matching Sets.]] |
;|| | ;|| | ||
:Match the “|” character. You need a double “||” to search for a single “|” in your text. A double “||” is also needed on the replacement side. | :Match the “|” character. You need a double “||” to search for a single “|” in your text. A double “||” is also needed on the replacement side. | ||
| + | |||
| + | ==Pattern Matching== | ||
| + | *[[Pattern_Matching_Newline|Pattern Matching the Newline]] | ||
| + | *[[Pattern_Matching_Beginning_End|Pattern Matching the Beginning / End]] | ||
| + | *[[Pattern_Matching_Multiple_Characters|Pattern Matching Multiple Characters]] | ||
| + | *[[Pattern_Matching_Sets|Pattern Matching Sets]] | ||
| + | *[[Registers_Search_Strings|Use Text Registers in Search Strings]] | ||
==Related Resources== | ==Related Resources== | ||
| + | *[[Main_Page| Wiki Home Page]] | ||
| + | *[[Search_And_Replace|Search & Replace Overview]] | ||
Pattern Matching makes it possible to search not only for particular characters, but also for types of characters such as “any digit” or for characters that meet special conditions such as "occurring at the beginning of a line”.
These generalized searches are performed by using “pattern matching codes” within the search string. Each pattern matching code consists of the special character “|” followed by another character, typically a mnemonic letter.