-2

I have a really long list of tuples that I want to insert into a database (db type is irrelevant for the question). I have to call a db function with all values from one day at a time. My question is now: how can I find the break between two days' rows? My data looks like this:

 /* '2020-01-01' */ ('UniqueKey', 'val1'), 
 /* '2020-01-01' */ ('UniqueKey', 'val2'), 
 /* '2020-01-01' */ ('UniqueKey', 'val3'), 
 /* '2020-02-01' */ ('UniqueKey', 'val1'), 
 /* '2020-02-01' */ ('UniqueKey', 'val2'), 
 /* '2020-02-01' */ ('UniqueKey', 'val3'), 
 /* '2020-02-01' */ ('UniqueKey', 'val4'), 
 /* '2020-02-01' */ ('UniqueKey', 'val5'), 

and I'd like to insert some code between the last line containing '2020-01-01' and the first line containing '2020-02-01' and so on, i.e. some code between any two lines that differ by date.

I am using Visual Studio Code, so a regex suitable for that editor would be appreciated, but any flavor of regex would do.

So which regex can I use for search and replace to insert my code snippet?

Geepy
  • 62
  • 1
  • 7
  • Can you present the desired output? – MonkeyZeus Dec 01 '20 at 13:58
  • Looking at the other answer ... is the part within the comment part of the data? Or is it just the ('UniqueKey', 'val1') part? Is the data part having 'val1' every time a new day starts? – Campfire Dec 01 '20 at 15:48

1 Answers1

-1

Check if the date on the next line (negative lookahead) is not the same date

Find: (/\* ('\d\d\d\d-\d\d-\d\d').*\n)(?!/\* \2)

Replace: $1BLA\n

rioV8
  • 24,506
  • 3
  • 32
  • 49