Search code examples
regexnotepad++

Notepad++ regex to get each unique number located between two recurring tags


I have 16k lines of text in a file. Opening it with Notepad++

Every few lines there is an occurrence like this one:

a few rows of text before
    Unique Identifier
    628612012-078
    Title
another few rows of text until the next Unique Identifier row

a few more lines of something else then it repeats again with a different number in between

a few rows of text before
Unique Identifier
1991-18613-001
Title
another few rows of text until the next Unique Identifier row

Picture of data:

enter image description here

What would a regex look like to get (copy/save) each id number located between each Unique Identifier and Title tag/row?

I don't mind if it deletes the rest of the text in the file or saves the output as another file or whatever. Ideally, I need to have just a list of those numbers occurring, in order.

Tried this/to adapt this Find and copy text between { and } in Notepad++ - couldn't get it to work


Solution

  • if the file has Unix(LF) line endings, the regex is

    (?<=Unique Identifier\n).+(?=\nTitle)
    

    then use Mark All and Copy Marked Text to get all mathes into Clipboard enter image description here