Reputation: 958
I have hundreds of string that take the form
""Foo, Baz" <foobaz>@fizz.com>"
I'm trying to use Query-replace-regexp
to replace those strings with
"""Foo, Baz"" <[email protected]>"
So far I have a pattern "\"\"[A-Z]+, [A-Z]+\""
but this doesn't match anything. I can't do a simple find/replace on ""
or "
because it will cause too many false hits. What the heck am I missing, how can crate a regex that matches my prescribed pattern?
Upvotes: 1
Views: 660
Reputation: 13442
The match is failing because you've put uppercase letters in your search string. From http://www.gnu.org/software/emacs/manual/html_node/emacs/Search-Case.html:
Searches in Emacs normally ignore the case of the text they are searching through, if you specify the text in lower case. Thus, if you specify searching for ‘foo’, then ‘Foo’ and ‘foo’ also match. Regexps, and in particular character sets, behave likewise: ‘[ab]’ matches ‘a’ or ‘A’ or ‘b’ or ‘B’.
An upper-case letter anywhere in the incremental search string makes the search case-sensitive. Thus, searching for ‘Foo’ does not find ‘foo’ or ‘FOO’. This applies to regular expression search as well as to string search. The effect ceases if you delete the upper-case letter from the search string.
Assuming the variable case-fold-search is set to t
(the default), then if you use this search text:
""[a-z]+, [a-z]+"
and this replacement text:
"\&"
Then query-replace-regexp
will convert this:
""Foo, Baz" <foobaz>@fizz.com>"
to this:
"""Foo, Baz"" <foobaz>@fizz.com>"
Upvotes: 1