I think (if i remember right.... tested some long long while ago using XP) this happens:
A doublequote character toggles an additional expansion phase (:= "doublequote expansion phase") between "on" and "off",
seperating the search string in "doublequoted" and "not doublequoted" parts.
Initially the state of this phase is "off".
Categorizing the doublequotes to:
- opening doublequote := a doublequote that toggles this state to "on".
- closing doublequote := a doublequote that toggles this state to "off".
- literal doublequote := a doublequote that does not toggle this state.
A doublequote following a "closing" doublequote or a '\' is a literal doublequote:
Code: Select all
"doublequoted"not_doublequoted"doublequoted"not_doublequoted
"doublequoted"""doublequoted"not_doublequoted
"doublequoted\"doublequoted"not_doublequoted
Note: A space in the 'not doublequoted' part ends the search string.
I haven't tested, if there are other characters that terminates the search string.
The opening and closing doublequotes are removed.
If a '\' follows a first '\', then the first '\' is removed (if it is not within a class block []), else it stays as is.
Code: Select all
"\"" --> \"
"\" --> \
"\\" --> \
"a\" --> a\
"a\b" --> a\b
Note: You may also 'escape' the doublequotes by using """.
Search strings using this notation are defaulted to regular expressions (separated by space characters):
Code: Select all
findstr "three regular expressions" file.txt
Search strings using this notation are defaultet to literally expressions (separated by space characters):
Code: Select all
findstr /C:"one literal expression"
Examples for this "doublequote expansion":
Code: Select all
search string --> matching pattern (interpreted "literally", or as a regular expresssion)
"\a" --> \a
"\"" --> \"
"\\" --> \
"\\\\" --> \\
"\\\\\\" --> \\\
"\\\\\\\\" --> \\\\
"[\\][\\]" --> [\\][\\]
"[\\\\][\\\\]" --> [\\\\][\\\\]
...
"\." --> \.
"\*" --> \*
"\^" --> \^
"\$" --> \$
"\[" --> \[
"\]" --> \]
"\<" --> \<
"\>" --> \>
penpen