Community
    • Login

    Find/replace

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    9 Posts 4 Posters 139 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.
    • balancedcircularB Offline
      balancedcircular
      last edited by

      Hello. I have a file in which are certain elements with their names. As I want to change names, need the most efficient way to do it.

      It looks like this: Name=“109 B29/Web 3”
      There is about 1000 of these names, but I would like to select all cases under quotation marks that come after Name=, delete first 4 places, and instead of Web 3 put W3.

      So, Name=“109 B29/Web 3” should look like Name=“B29/W3”.

      Is it possible?

      Terry RT CoisesC 3 Replies Last reply Reply Quote 0
      • Terry RT Offline
        Terry R @balancedcircular
        last edited by

        @balancedcircular

        It is very easily achieved using regular expressions in Notepad++. Have you tried anything yet?

        Someone can easily make it for you, but we like to know first if the poster has tried anything first.

        Terry

        balancedcircularB 1 Reply Last reply Reply Quote 0
        • Terry RT Offline
          Terry R @balancedcircular
          last edited by Terry R

          @balancedcircular said:

          So, Name=“109 B29/Web 3” should look like Name=“B29/W3”.

          I should also add that you need to insert the original data within a code box. Please read the FAQ post called Template for Search/Replace Questions. In your case the double quotation marks you typed have possibly been converted to another type of quote character. Entering examples in the code box prevents this.

          You should also elaborate on what the transformation is.
          Currently it looks like:

          1. remove 4 characters after quote character.
          2. take characters until a / reached, include this and 1 following character.
          3. take the last character before the quote character and include that and the quote.
          4. return the assembled string.

          However since you did not explain the transformation, it could well be for #3, take all numbers and return them (rather than just the last character).

          Terry

          1 Reply Last reply Reply Quote 0
          • balancedcircularB Offline
            balancedcircular @Terry R
            last edited by

            @Terry-R
            Well, to be honest, this isn’t my area, so that’s why I tried to ask for help.
            To try anything else beside standard find/replace inputs, I need to study manual, but additionally understand meaning of all options. In a stressful lifestyle, time is what I miss the most.

            If you, or anybody else can guide me, I would be thankful.

            Terry RT 1 Reply Last reply Reply Quote 0
            • Terry RT Offline
              Terry R @balancedcircular
              last edited by Terry R

              @balancedcircular

              We accept that not everyone can suddenly do regex (regular expressions) but admitting it means we will be happy to help. It’s when users just believe we are a source to be used, rather than the assistance and guidance we’d prefer to try.

              You will however need to read my last post as your detail is lacking in substance. Without it we could be on a wild goose chase wasting time back and forwards.

              By explaining the transformation to us (and to yourself as you write it) can often show some clarity and maybe you might also be able to achieve it by yourself, or at least get closer to the solution with our help.

              Terry

              1 Reply Last reply Reply Quote 0
              • guy038G Offline
                guy038
                last edited by guy038

                Hello, @balancedcircular, @terry-r and All,

                In other words, @terry-r suggests that you, both, show us some lines which could stand as an INPUT text and some other lines which could stand as an OUTPUT text !

                When inserting these sections, use the </> icon in your future post, to include them as code / raw text !

                f65d36f1-f1a7-455a-b9a2-8e235626611c-image.jpeg


                For example, the INPUT text could be :

                Name="109 B29/Web 3"
                Name="279 A658/Web 45"
                Name="56247 H3/Web 123"
                Name="1234 B987/Web 10"
                

                And the OUTPUT text could be :

                Name="B29/W3"
                Name="A658/W45"
                Name="7 H3/W123"
                Name=" B987/W10"
                

                Where :

                • The first four characters, after the string Name", are omitted

                • The next characters until the slash and the uppercase letter W are kept

                • All remaining digits and the closing quote are also kept

                This is just an example and it’s up to you to tell us all or , at least, the most cases that may occur !


                Best Regards,

                guy038

                1 Reply Last reply Reply Quote 0
                • CoisesC Offline
                  Coises @balancedcircular
                  last edited by Coises

                  @balancedcircular said:

                  Hello. I have a file in which are certain elements with their names. As I want to change names, need the most efficient way to do it.

                  It looks like this: Name=“109 B29/Web 3”
                  There is about 1000 of these names, but I would like to select all cases under quotation marks that come after Name=, delete first 4 places, and instead of Web 3 put W3.

                  So, Name=“109 B29/Web 3” should look like Name=“B29/W3”.

                  Is it possible?

                  Try this:

                  • First, make a backup copy of your file in case something goes wrong and you don’t notice it right away.

                  • Open the file in Notepad++.

                  • Select from the main menu Search | Replace.

                  • Fill in the dialog this way:

                  Find what: Name="\d\d\d (.*/W)eb\h
                  Replace with: Name="$1
                  Match case not checked
                  Wrap around checked
                  Search Mode: Regular expression
                  . matches newline not checked

                  • then click Replace All.

                  Examine carefully and see if that did what you wanted. If it didn’t, make a note of what went wrong, close the file without saving, and tell us what wasn’t right.

                  balancedcircularB 1 Reply Last reply Reply Quote 1
                  • balancedcircularB Offline
                    balancedcircular @Coises
                    last edited by

                    Thank you all for your replies.

                    @Terry-R honesty is the best approach always, because if you get trapped in lies, it is hard to track what did you say and to whom :)

                    After reading other responses, it should be like this:

                    • remove 4 characters after quote character - it should remove all characters until a letter B, because it could also be a 4 digit number, or two digits…
                    • take characters until a / reached, include this and 1 following character. - ok
                    • take the last character before the quote character and include that and the quote. - take numbers before the quote character
                    • return the assembled string. - also if possible write it in Comments too.
                    <RectangularPart Version="2.1.6" DimensionY="50" DimensionZ="80" Name="007 B19/Web 3" PartId="7" PartNo="7" ReqQuantity="1" Unit="19" Grade="C24" Comments="FirstFloor">
                    

                    It should look like this. So if it is also possible to copy and replace text from Name part to Comments part.

                    <RectangularPart Version="2.1.6" DimensionY="50" DimensionZ="80" Name="B19/W3" PartId="7" PartNo="7" ReqQuantity="1" Unit="19" Grade="C24" Comments="B19/W3">
                    
                    <RectangularPart Version="2.1.6" DimensionY="50" DimensionZ="120" Name="001 B19/Rafter 1" PartId="1" PartNo="1" ReqQuantity="1" Unit="19" Grade="C24" Comments="FirstFloor">
                    

                    Should look like this:

                    <RectangularPart Version="2.1.6" DimensionY="50" DimensionZ="120" Name="B19/R1" PartId="1" PartNo="1" ReqQuantity="1" Unit="19" Grade="C24" Comments="B19/R1">
                    

                    @guy038
                    It would be better to omit all characters until capital B.
                    Keep all, until uppercase W.
                    Keep all digits.
                    Copy from Name section to Comment section.

                    @coises
                    Tried it, and it works great! But, as I thought a little bit more, there is a possibility for other digits to appear. If it is possible, it would be great to copy from Name to Comments section.

                    Additionally, is it possible to connect two search/replace in one like macro? So, I have Rafter, C.Tie, Web. Is there a way to connect three different searches in one?

                    Thank you all.

                    1 Reply Last reply Reply Quote 0
                    • guy038G Offline
                      guy038
                      last edited by guy038

                      Hello, @balancedcircular, @terry-r, @coises and All,

                      I suppose that the following regex S/R should be close to what you want ! I consider the entire line because you may have other lines with attributes Name and/or Comments


                      FIND (?-si)^(<RectangularPart Version=.+ Name=")\d\d\d (.+/.).+?(\d")(.+ Comments=").+(?=>)

                      REPLACE $1$2$3$4$2$3

                      As @coises said, try this global replacement on a copy of your file !


                      If everything works as expected, I’ll explain you, next time, how all the regex syntax means !

                      Best Regards,

                      guy038

                      I almost forgot the last line of your post. To simultaneously search for any of the three words Rafter, C.Tie and Web, simply use the regex (?-i)Rafter|C\.Tie|Web

                      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