Community
    • Login

    is it possible to highlight all strings based on the field delimiter?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 2 Posters 689 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.
    • Eddie Jr. PanesE
      Eddie Jr. Panes
      last edited by

      so i have a lot of data that contains a header and values of different sizes. I want to easily locate the values under each header. I can import it into a spreadsheet but that takes a lot of time. Is there a quicker way to achieve this with notepad++?

      example:

      field1;field2;field3;field4;field5
      1;2;3;4;5
      5;4;3;2;1

      I want to be able to select “field4” and “4” and “2” will also be highlighted. They are all the strings after the 3rd field delimiter and vice versa. this will be a great visual clue.

      thanks and appreciate any help .

      Alan KilbornA 1 Reply Last reply Reply Quote 1
      • Alan KilbornA
        Alan Kilborn @Eddie Jr. Panes
        last edited by

        @Eddie-Jr.-Panes

        Here’s kind of a hacky way to do it:

        Do a MARK operation (see the Find window tab for “mark”).

        Put (?-s)^([^;]+;){FIELDMINUS1}\K([^;\r\n]+) in the find what box (but see below first!)
        Tick Wrap around box
        Tick Regular expression search mode

        See where I put FIELDMINUS1 in the find what? Put a real number in there. So to continue your example if you want field 4 you would put a 3 in for FIELDMINUS1, to wit: (?-s)^([^;]+;){3}\K([^;\r\n]+)

        Then press the Mark All button.

        Eddie Jr. PanesE 1 Reply Last reply Reply Quote 1
        • Eddie Jr. PanesE
          Eddie Jr. Panes @Alan Kilborn
          last edited by

          @Alan-Kilborn

          Hi Alan, thanks it worked! and based on the code; i just have to replace ‘;’ with ‘,’ for CSV files.

          Alan KilbornA 1 Reply Last reply Reply Quote 1
          • Alan KilbornA
            Alan Kilborn @Eddie Jr. Panes
            last edited by

            @Eddie-Jr.-Panes

            I worked on it further and came up with something more generic:

            (?-s)^(?:.*?(;|,|\t)){FIELDMINUS1}\K(?:.*?)(?=(?1)|\R|\z)

            It will match various delimiters: ; or , or tab. To add or remove delimiters, just change this part of it: (;|,|\t)

            It will also work (and highlight nothing) for a field if that field position occurs in the middle of two consecutive field delimiters (also stated as two delimiters occurring back to back).

            I saw a slight problem. If FIELDMINUS1 is zero, and the first field in the data to be matched is empty (meaning a line starts off with a delimiter rather than non-delimiter), then the match is incorrect. Maybe guru of gurus @guy038 could fix this problem,?

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