Community
    • Login

    Search and Replace

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    7 Posts 3 Posters 1.2k Views 2 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.
    • Claude MartinC Offline
      Claude Martin
      last edited by

      Fellow Notepad++ Users,

      Could you please help me with the following search-and-replace problem I am having?

      I need to search and replace in different documents with a line like
      <property name=“CarryWeight” value=“1”/>

      The value changes and can be any number and I want to rplace the value with a number of my choosing.

      Here is the data I currently have (“before” data):

      <property name="CarryWeight" value="1"/>
      <property name="CarryWeight" value="20"/>
      
      Here is how I would like that data to look (“after” data):
      
      <property name="CarryWeight" value="0"/>
      <property name="CarryWeight" value="0"/>
      
      I feel this is something thats doable but my last computer class was in 1972 and I don'
      remember Fortran covering this. :)
      Thanks
      Alan KilbornA 1 Reply Last reply Reply Quote 0
      • Alan KilbornA Offline
        Alan Kilborn @Claude Martin
        last edited by

        @Claude-Martin

        Are you saying your doc has other “property name” sections, but you only want to change your value in those that have the name CarryWeight?

        Claude MartinC 1 Reply Last reply Reply Quote 0
        • Claude MartinC Offline
          Claude Martin @Alan Kilborn
          last edited by Claude Martin

          @Alan-Kilborn Yes. I could search and replace manually but three of the files have over 7000 lines of code.

          Alan KilbornA 1 Reply Last reply Reply Quote 0
          • Alan KilbornA Offline
            Alan Kilborn @Claude Martin
            last edited by

            @Claude-Martin

            What you want is to search and replace only between other text. We have a prior solution for that. See if you can follow the RECIPE for that, but for your specific data.

            Claude MartinC Neil SchipperN 2 Replies Last reply Reply Quote 0
            • Claude MartinC Offline
              Claude Martin @Alan Kilborn
              last edited by

              @Alan-Kilborn Thank you I’ll give a go.

              1 Reply Last reply Reply Quote 0
              • Neil SchipperN Offline
                Neil Schipper @Alan Kilborn
                last edited by

                @Alan-Kilborn said in Search and Replace:

                What you want is to search and replace only between other text.

                You may be right, but nothing in what @Claude-Martin originally showed, nor in the subsequent exchange between you, supports the need for selectively acting on property name="CarryWeight" lines bound by specified higher level tags.

                My reading of the need leads me to think simple regex solutions should be satisfactory:

                
                1) replace a specific group of nums with a specific num
                
                Fi: <property name="CarryWeight" value="(?:1|3|15|20)"/>
                Re: <property name="CarryWeight" value="PLACE_NEW_NUM_HERE"/>
                
                or
                
                2) replace all nums with a specific num
                
                Fi: <property name="CarryWeight" value="\d+"/>
                Re: <property name="CarryWeight" value="PLACE_NEW_NUM_HERE"/>
                
                
                Alan KilbornA 1 Reply Last reply Reply Quote 2
                • Alan KilbornA Offline
                  Alan Kilborn @Neil Schipper
                  last edited by

                  @Neil-Schipper

                  Yes, indeed, it may very well be the simpler case. I was fooled because so often these go the other way. :-)

                  1 Reply Last reply Reply Quote 2

                  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