Community
    • Login

    How to write parentheses in replacement, using the "Regular expression" mode ?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 3 Posters 10.9k Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • guy038G Offline
      guy038
      last edited by guy038

      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 :D

      As 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 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

      1 Reply Last reply Reply Quote 2
      • Vuvanvui VuiV Offline
        Vuvanvui Vui
        last edited by

        thanks a lot ;)

        1 Reply Last reply Reply Quote 0
        • 古旮古 Offline
          古旮
          last edited by

          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.

          1 Reply Last reply Reply Quote 1
          • 古旮古 Offline
            古旮
            last edited by

            Funny enough: another same question.

            1 Reply Last reply Reply Quote 0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors