xml - find first instance of a date using regex -


i'm trying find/replace xml file of tide data in submlimetext2 , i'm stumped multiple instances of same date. here's sample of data:

<item>   <date>2016/01/01</date>   <time>06:16 am</time>   <predictions_in_ft>8.2</predictions_in_ft>   <predictions_in_cm>250</predictions_in_cm>   <highlow>h</highlow> </item> <item>   <date>2016/01/01</date>   <time>12:31 pm</time>   <predictions_in_ft>3.0</predictions_in_ft>   <predictions_in_cm>91</predictions_in_cm>   <highlow>l</highlow> </item> <item>   <date>2016/01/01</date>   <time>06:13 pm</time>   <predictions_in_ft>6.6</predictions_in_ft>   <predictions_in_cm>201</predictions_in_cm>   <highlow>h</highlow> </item> 

what i'm trying preserve first instance of date, remove subsequent dates arrive @ this:

<item>   <date>2016/01/01</date>   <time>06:16 am</time>   <predictions_in_ft>8.2</predictions_in_ft>   <predictions_in_cm>250</predictions_in_cm>   <highlow>h</highlow> </item> <item>   <time>12:31 pm</time>   <predictions_in_ft>3.0</predictions_in_ft>   <predictions_in_cm>91</predictions_in_cm>   <highlow>l</highlow> </item> <item>   <time>06:13 pm</time>   <predictions_in_ft>6.6</predictions_in_ft>   <predictions_in_cm>201</predictions_in_cm>   <highlow>h</highlow> </item> 

any ideas? know xml parser of kind more handy, i'm noob , getting job done on time.

you can try pattern:

(?|\g(?<=(.{10})</date>\n[ ]{2})[^<]*|<date>([^<]+))(?:<(?!date>)[^<]*)*+\k<date>\1</date>\n[ ]{2} 

demo

if doesn't work add \r before each \n.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -