Boolean Expressions

There are several ways to make use of Boolean Expressions.

1. Direct Search Expression: The boolean symbols ‘&’, ‘|’, and ‘~’ which stand for ‘AND’, ‘OR’, and ‘NOT’ can be used directly in the Search For: field in the main dialog. To use this functionality, disable Regular Expression, HTML mode, and Ignore Whitespace Mode if they are on and enable Whole Word mode. For example, to find files that contain the words ‘this’ and ‘that’, use (don’t include the S: part):
    S: this&that
See Direct Boolean Expressions for more information.

2. Regular Expressions *[] Operator: The *[] expression, which matches all characters and spans lines, can function like an ‘and’ operator of sorts. For example, to search for Susan and Bill in the same file you might use the regular expression search term
    S: Susan*[]Bill
This is not very elegant of course.

3. Regular Expressions | Operator: The regular expression ‘or’ operator is also available. Example:
    S: (Susan|Bill)
This can also be used in more complex expressions -
    S: (Susan|Bill)*[](Susan|Bill)
Overlapping search hits may be a problem with the above so it is best that you have some familiarity with your files before using the above in replaces.

4. Regular Expressions ! Operator: The regular expression ‘not’ operator is somewhat more elegant than the above. By using an empty ! expression, !(), you can cause the program to do ‘and’ searches. For example,
    S: DDX_Text*!()m_strSearchExpr
would find
    DDX_Text(pDX, IDC_SEARCH_EXP_ED, m_strSearchExpr);
but not
    DDX_Text(pDX, IDC_REPLACE_EXP_ED, m_strReplaceExpr);

5. Scripts Boolean Expression Evaluator: The ‘Process file when expression is non-zero’ field in the Advanced tab of the Script Dialog lets you make choices about which file(s) will be processed by a script. Search terms in the script are referenced by the E1, E2, … En… variables, where n is the number of search terms in your script. The default expression is an ‘OR’ expression. If you are using anything other than an ‘OR’ expression be sure to review the section on Expression Evaluator and Replacement Prompts. When making replacements the program offers confirmations (if replace confirmations are enabled) for all places where a search hit exists. This is for debugging purposes. Expression Evaluator and Replacement Prompts. provides more detail about this.

Note: Also see Search Replace Current Files for another form of ‘boolean’ functioning. Search and Replace has special keyboard shortcuts to perform follow-up operations on only the files listed in the current Search Results list.

Boolean Expressions