I have a list like following:
hrthrhthrht
bntyjhytjtyj
8,083,344
Mar1996
tggrgge
Now I need a notepad++ regex that bookmark two following lines:
8,083,344
Mar1996
this mean two consecutive lines that first line start with a digit and second line include only a date or following regex:
\b(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\d{4}\b
I tried following regular expressions but not worked for me:
^[^\d\r\n]*(?:\D*(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\d{4})[^\d\r\n]*$
^[^\d\r\n]*(?:\D*(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\d{4})[^\d\r\n]*\R[^\d\r\n]*(?:\D*(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\d{4})[^\d\r\n]*$
^[^\d\r\n]*(?:\D*(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\d{4})[^\d\r\n]*\R[^\d\r\n]*(?:\D*(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\d{4})[^\d\r\n]*$
^[^\d\r\n].*\R\b(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\d{4}\b.*$
^[^\d\r\n].*\R^[^\d\r\n].*\b(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\d{4}\b.*$
^[^\d\r\n].*\R[^\d\r\n].*\b(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\d{4}\b.*$
^[^\d\r\n].*\R^[^\d\r\n].*\b(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\d{4}\b
^[^\d\r\n].*\R[^\d\r\n].*(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\d{4}\b
where is problem?
note that first line should start with a digit.
>Solution :
You may use this regex to match 2 consecutive lines as desired:
^\d+(?:,\d+)*\r?\n[^\d\r\n]*(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\d{4}[^\d\r\n]*$
RegEx Details:
^: Line Start\d+(?:,\d+)*: Match 1+ digits then match 0 or more sets of comma followed by 1+ digits\r?\n: Match a line break[^\d\r\n]*: Match 0 or more of any character that are not a digit and not a line break(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec): Match month string\d{4}: Match 4 digits[^\d\r\n]*: Match 0 or more of any character that are not a digit and not a line break$: Line End