Community
    • Login

    replace all text in a bracket

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    8 Posts 3 Posters 1.5k 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.
    • daniel LouwrensD
      daniel Louwrens
      last edited by

      Hi

      Please let me know how to replace all text in a bracket.

      Example

      xxxx ( xxxx xxx )
      Replaced with
      xxxx ( yyyyyyy )

      daniel LouwrensD Terry RT 2 Replies Last reply Reply Quote 0
      • daniel LouwrensD
        daniel Louwrens @daniel Louwrens
        last edited by

        @daniel-Louwrens said in replace all text in a bracket:

        Hi

        Please let me know how to replace all text in a bracket.

        Example

        xxxx ( xxxx xxx )
        Replaced with
        xxxx ( yyyyyyy )

        Sorry, I should have mentioned that the words in the bracket will be varied for
        all instances.

        1 Reply Last reply Reply Quote 0
        • Terry RT
          Terry R @daniel Louwrens
          last edited by

          @daniel-Louwrens

          There is a generic formula created available in the FAQ section, see this post and the link from there called “Replacing in a specific zone of text”. Try that.

          Also when posting these types of questions it is preferable to insert examples in a specific method, please read the post pinned to this section called “Please Read this before Posting”.

          Terry

          daniel LouwrensD 1 Reply Last reply Reply Quote 0
          • daniel LouwrensD
            daniel Louwrens @Terry R
            last edited by

            @Terry-R

            Hi

            I have had a look at the FAQs and the recommended methods for posting
            but I am still unsure how to proceed.

            Using Search/find in files then Find What…

            Name ( “BTI_BCNA” ) text will be different every time, always in inverted commas

            Replace with

            Name ( “Loose Consist” ) This will be the same every time

            I hope that clarifies the question

            Regards

            Daniel

            Terry RT CoisesC 2 Replies Last reply Reply Quote 0
            • Terry RT
              Terry R @daniel Louwrens
              last edited by Terry R

              @daniel-Louwrens said in replace all text in a bracket:

              I have had a look at the FAQs and the recommended methods for posting
              but I am still unsure how to proceed.

              I don’t know if you are unwilling or unable to post examples correctly. Regardless I will give you a possible solution. If it doesn’t work it will be because you didn’t post the examples as requested. Not showing examples in the format requested is often the main cause for failure of the solution, so be it!

              Whilst this doesn’t look anything like the other post I referred to, it does follow reasonably well. This solution will only work for your example, whereas the other post has to cater for lots of different scenarios, hence it looks more complicated.

              Find What:\([^)]+
              Replace With:\( xyz

              This used the Replace function, search mode is set to “regular expression”. You can copy and paste the red text above into the respective fields. Obviously xyz isn’t correct, you will need to replace that with what you want to insert as the replacement text.

              Good luck
              Terry

              1 Reply Last reply Reply Quote 1
              • CoisesC
                Coises @daniel Louwrens
                last edited by

                @daniel-Louwrens said in replace all text in a bracket:

                I have had a look at the FAQs and the recommended methods for posting
                but I am still unsure how to proceed.

                Using Search/find in files then Find What…

                Name ( “BTI_BCNA” ) text will be different every time, always in inverted commas

                Replace with

                Name ( “Loose Consist” ) This will be the same every time

                Try:

                Find what: (Name\s*\(\s*")(.*?)("\s*\))
                Replace with: \1Loose Consist\3

                That’s assuming the text before the open parenthesis is always “Name”; if it varies, try removing (Name\s* from the beginning and see if it selects what you want without selecting things you don’t want.

                daniel LouwrensD 1 Reply Last reply Reply Quote 2
                • daniel LouwrensD
                  daniel Louwrens @Coises
                  last edited by

                  @Coises said in replace all text in a bracket:

                  @daniel-Louwrens said in replace all text in a bracket:

                  I have had a look at the FAQs and the recommended methods for posting
                  but I am still unsure how to proceed.

                  Using Search/find in files then Find What…

                  Name ( “BTI_BCNA” ) text will be different every time, always in inverted commas

                  Replace with

                  Name ( “Loose Consist” ) This will be the same every time

                  Try:

                  Find what: (Name\s*\(\s*")(.*?)("\s*\))
                  Replace with: \1Loose Consist\3

                  That’s assuming the text before the open parenthesis is always “Name”; if it varies, try removing (Name\s* from the beginning and see if it selects what you want without selecting things you don’t want.

                  Hi

                  I tried a find and replace using the exact chars you suggested but
                  the program showed 0 replaced.

                  Cheers

                  Daniel

                  Terry RT 1 Reply Last reply Reply Quote 0
                  • Terry RT
                    Terry R @daniel Louwrens
                    last edited by

                    @daniel-Louwrens said in replace all text in a bracket:

                    I tried a find and replace using the exact chars you suggested but
                    the program showed 0 replaced.

                    Did you set the search mode to regular expression?

                    If that isn’t the issue then you need to provide the examples via the requested method. Follow that post I referred to, otherwise you are just wasting people’s time on this forum (who do want to help).

                    Terry

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