How to write parentheses in replacement, using the "Regular expression" mode ?
-
Hi, @vuvanvui-vui, and All,
@vuvanvui-vui send me an e-mail, today, saying :
hello Guy, how are you today,
hmm i have a question on notepad ++in Regular express mode i can’t replace something = “(”, “)”
exam: i want to replace: Guy = (Guy)
the () is lost in result
thanks and sorry for my bad english :DAs I think that the solution may be useful for others, I prefer to reply on our site !
Quite easy ! In the Replacement zone, you must simply escape the parentheses with the usual
\
symbol ;-)). So :SEARCH
Guy
REPLACE
\(Guy\)
( or even\x28Guy\x29
)Notes :
-
The
six
characters, which have to be escaped, with the backslash\
symbol, are :- The backslash symbol
\
- The left parenthesis
(
- The right parenthesis
)
- The dollar sign
$
- The question mark punctuation sign
?
- The colon punctuation sign
:
- The backslash symbol
-
The above signs have a specific meaning, in the Boost Format String library ! Just refer to :
http://www.boost.org/doc/libs/1_55_0/libs/regex/doc/html/boost_regex/format/boost_format_syntax.html
- Most of the time, in replacement, the
$
,?
and:
symbols do not need to be escaped !
Cheers,
guy038
-
-
thanks a lot ;)
-
Haha. This is a question I asked more than a year ago, to which guy038 also gave valuable reply.
Seriously, is there a way to edit NPP wiki? I can’t find how to register. And the Regular Expression Page is incomplete and still has some obvious errors. -
Funny enough: another same question.