Community
    • Login

    Search Multiple Columns

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    13 Posts 3 Posters 1.1k 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.
    • Tom GrisafeT
      Tom Grisafe
      last edited by

      I tried ^.{41}TH1352 and it returned the data up to TH1352 just fine but when I changed to ^.{41}TH1352.{56}100 then it couldn’t find, any thoughts ?

      1 Reply Last reply Reply Quote 0
      • Tom GrisafeT
        Tom Grisafe
        last edited by

        Here’s the expression I tried; ^.{41}TH1352.{56}100.{62}20220101.{154}D.{71}004 and here’s the data
        df31aa5c-ed36-4863-a6a8-4b9ee15c08ed-image.png . I tried breaking up the expression and do one at at time and it found all so positioning is correct so not sure why it doesn’t work, any help appreciated.

        Alan KilbornA 1 Reply Last reply Reply Quote 0
        • Alan KilbornA
          Alan Kilborn @Tom Grisafe
          last edited by

          @Tom-Grisafe

          Nobody wants to type your data from a screenshot so they can run a test on it.
          Post TEXT data!

          1 Reply Last reply Reply Quote 0
          • Tom GrisafeT
            Tom Grisafe
            last edited by

            Actual Data;

            9996F48J999 NEWS HOOEY M219520713TH135226470000 10061 202201010004 20210406020210401 H13520022021033101N00000000.0000000.00MD

            Alan KilbornA PeterJonesP 2 Replies Last reply Reply Quote 0
            • Alan KilbornA
              Alan Kilborn @Tom Grisafe
              last edited by Alan Kilborn

              @Tom-Grisafe said:

              ^.{41}TH1352.{56}100.{62}20220101.{154}D.{71}004

              9996F48J999 NEWS HOOEY M219520713TH135226470000 10061 202201010004 20210406020210401 H13520022021033101N00000000.0000000.00MD
              

              Your regular expression matches your data so poorly that I think you’d better build it up one step at a time.

              This will match the first part – ^.{33}TH1352 – do you understand why?

              After that there are two parts of it that match 100. Which one do you want?

              1 Reply Last reply Reply Quote 1
              • PeterJonesP
                PeterJones @Tom Grisafe
                last edited by PeterJones

                @Tom-Grisafe said in Search Multiple Columns:

                Actual Data;

                9996F48J999 NEWS HOOEY M219520713TH135226470000 10061 202201010004 20210406020210401 H13520022021033101N00000000.0000000.00MD

                But that’s not the actual data, as shown by your screenshot showing some sort of spacing:

                You could have easily seen this in the PREVIEW window while entering your post – that should have indicated to you that maybe you needed to apply some sort of formatting in your post to better communicate the data. By doing a view source, I was able to find text that had extra spaces compared to what we could see, and I am hoping that data is closer to what you typed (but the Forum may still have edited it from what you originally typed).

                On the other hand, if you had read the “Read This Before Posting” and “Template for Search/Replace Questions” that I linked you to earlier, you would have seen how to shown us your data like this:

                9996F48J999 NEWS        HOOEY  M219520713TH135226470000 10061 202201010004 20210406020210401                       H13520022021033101N00000000.0000000.00MD
                

                which properly shows the spacing. The reason why I linked you to those was not because I like the typing; it’s because I knew that by following the advice in those posts, you could ask your question in a way that we could immediately understand, rather than making us dig for actual data or beg you to clarify.

                With this version of your data, it puts the “100” in columns 57-59 like you originally said, so I believe this data actually represents what you have.

                Now, to correct your misunderstanding with your attempted ^.{41}TH1352.{56}100: the number in braces is not the column number. It is the number of repeats of the previous token in the regex. So my original ^.{56}100.{12}004.{10}20220101 said “match the beginning of the line with ^, then 56 instances of any character .{56}, follwed by the digits 100 followed by 12 instances of any character .{12}, etc”. Note that I didn’t have {56} and {71} in that expression to start the next token at columns 57 then at 72: I used .{56} to consume 56 characters in the search, then match 3 characters in 100, then used .{12} to move forward another 12 characters after the 100: 56+3+12=71 => so that’s why 71 characters were consumed. Thus, the 004 matches the characters in columns 72-74.

                So, what your expression ^.{41}TH1352.{56}100 said was "start at the beginnning of the line, move forward 41 characters, then match TH1352 (in columns 42-47), then move forward an additional 56 characters (through character 103), and then try to match 100 in the next three characters (columns 104-106). Since your 100 are in characters 57-59, not in 104-106, the regex you tried won’t match.

                Given that information, and what @Alan-Kilborn showed with the non-spaced version, please try again to modify my original to match your new requirements.

                Notes:

                • ^ is described in the “anchor” section of the Notepad++ Online User Manual’s regex docs
                • . is described in the “single character matches” section of the Notepad++ Online User Manual’s regex docs
                • {##} is described in the “mulitplying operators” section of the Notepad++ Online User Manual’s regex docs
                Alan KilbornA Tom GrisafeT 2 Replies Last reply Reply Quote 0
                • Alan KilbornA
                  Alan Kilborn @PeterJones
                  last edited by

                  @PeterJones said in Search Multiple Columns:

                  But that’s not the actual data

                  OMG, the effort it takes to answer these types of questions is more than it is worth.

                  1 Reply Last reply Reply Quote 2
                  • Tom GrisafeT
                    Tom Grisafe @PeterJones
                    last edited by

                    @PeterJones @Alan-Kilborn Using the following data, I was able to get this formula to work; ^.{41}TH1352.{09}100.{03}20210401.{01}001.{80}B

                    99999999999 HOOOEY YOONNE M219520713TH135226470000 10061 202104010001 20210406020210401 H13520022021033101N00000000.0000000.00MB

                    If I am understanding correctly, the first parm {41} is the starting point and I just figured the nbr of pstns to the next field of 100 and so on etc… ?

                    ** I apologize for not reading ahead of time in how to Post but appreciate all the Help !!

                    Alan KilbornA 1 Reply Last reply Reply Quote 0
                    • Alan KilbornA
                      Alan Kilborn @Tom Grisafe
                      last edited by

                      @Tom-Grisafe said in Search Multiple Columns:

                      If I am understanding correctly, the first parm {41} is the starting point

                      Hard for us to tell if you are understanding…

                      The {41} does not act alone. It acts with what comes to the left of it.
                      In this case . comes to the left of it.
                      In regular expressions, . (usually) means “any one character”.

                      Because the ^ means start of line, .{41} will "consume the first forty-one characters on a line, no matter what they are. Then if the next character is a T you have the possibility of a match. And the expression grows from there.

                      Get it?

                      1 Reply Last reply Reply Quote 2
                      • Tom GrisafeT
                        Tom Grisafe
                        last edited by

                        Yes, makes sense. Pretty new to all the functionality in Notepad++, especially Reg Expressions so a little overwhelming but again appreciate the Help.

                        Any good site that completely explains Reg Expressions with Examples.

                        PeterJonesP 1 Reply Last reply Reply Quote 0
                        • PeterJonesP
                          PeterJones @Tom Grisafe
                          last edited by PeterJones

                          @Tom-Grisafe said in Search Multiple Columns:

                          Any good site that completely explains Reg Expressions with Examples.

                          Yes. The FAQ for regular expressions has plenty. I linked this to you already, in my first reply to you.

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