notepad++

Notepad++ - mark only 12 characters between commas and list them


There are different amount of characters between commas. I had been trying to mark only the one with 12 characters between two commas in each row in Notepad++ and list them.

EX:

I want to turn this:

1234,abc1.2,34:56ab,MarkThis1234,UH3fefa33dfsuuF
123,ab-4.56,78:90,aBcD#1,mARKtHIS4321,AbCd,987

Into this:

MarkThis1234
mARKtHIS4321

Any help is appreciated, Thank you <3


Solution

  • Doing a regex ReplaceAll of (^|,)([^,\r\n]{0,11}|[^,\r\n]{13,})(,|$) with \r\n converts all of the unwanted items into line breaks, then menu => Edit => Line operations => Remove empty lines removes the unwanted empty lines; leaving only the wanted text.

    The regex has three parts. First begining-of-line or a comma. Lastly end-of-line or a comma. Between them is non-commas that are not exactly eleven characters in length. This last is achieved by looking for eith under 11, or over 11.

    (^|,)                  Beginning-of-line, or a comma.
    (                      Either
        [^,\r\n]{0,11}         0 to 11 characters, not a comma, LR or CR
    |                      Or
        [^,\r\n]{13,}          13 or more characters, not a comma, LR or CR
    )
    (,|$)                  End-of-line, or a comma.
    

    All three of theses groups could be non-captuting (i.e. using (?:...)) but I not shown that so as to concentrate on the important parts of the regex.