Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Bookmark two consecutive lines that second line include only a date

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

\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 Demo

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
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading