• Login
Community
  • Login

RegEx omitting the round brackets

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
6 Posts 2 Posters 1.0k Views
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.
  • S
    Scott Nielson
    last edited by Scott Nielson Jun 20, 2021, 4:55 PM Jun 20, 2021, 4:53 PM

    My RegEx is omitting the round brackets despite putting that in the Replace all/Replace in files field
    I used this (<a name="\d+")(><b>)([^<]*)(?=</b></a></td>) in the find field and this $1 style="color: rgb(44, 121, 179); text-decoration: none;"$2<span style="line-height: 20px; font-family: Verdana,sans-serif; color: rgb(137, 155, 52); font-size: 13.5pt;">$3</span> in the Replace all/Replace in files field.
    How do I get the brackets on replacing something that should have brackets?

    P 1 Reply Last reply Jun 20, 2021, 5:37 PM Reply Quote 0
    • P
      PeterJones @Scott Nielson
      last edited by PeterJones Jun 20, 2021, 5:38 PM Jun 20, 2021, 5:37 PM

      @Scott-Nielson ,

      Parentheses (round brackets) carry meaning in the replacement, so you have to escape them:. \( and \)

      S 2 Replies Last reply Jun 20, 2021, 5:56 PM Reply Quote 0
      • S
        Scott Nielson @PeterJones
        last edited by Jun 20, 2021, 5:56 PM

        This post is deleted!
        1 Reply Last reply Reply Quote 0
        • S
          Scott Nielson @PeterJones
          last edited by Jun 20, 2021, 6:03 PM

          @PeterJones I added the \ just before the opening bracket as well as the closing bracket but it ain’t working. Please help!

          P 1 Reply Last reply Jun 20, 2021, 6:22 PM Reply Quote 0
          • P
            PeterJones @Scott Nielson
            last edited by PeterJones Jun 20, 2021, 6:22 PM Jun 20, 2021, 6:22 PM

            @Scott-Nielson ,

            escaping parentheses works perfectly well in Notepad++ regular expressions.

            and your regex, when modified to escape the parens, works perfectly well for me:

            • FIND = (<a name="\d+")(><b>)([^<]*)(?=</b></a></td>)
            • REPLACE = $1 style="color: rgb\(44, 121, 179\); text-decoration: none;"$2<span style="line-height: 20px; font-family: Verdana,sans-serif; color: rgb\(137, 155, 52\); font-size: 13.5pt;">$3</span>
            S 1 Reply Last reply Jun 20, 2021, 6:30 PM Reply Quote 1
            • S
              Scott Nielson @PeterJones
              last edited by Jun 20, 2021, 6:30 PM

              @PeterJones yea, it worked. I had a </p> in my next search - that’s why it di’n’t work before. Thanks a lot man!

              1 Reply Last reply Reply Quote 0
              5 out of 6
              • First post
                5/6
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors