sed-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Regular expression differences between sed 4.2.2 and 4.5


From: SAMUEL VISCAPI
Subject: Regular expression differences between sed 4.2.2 and 4.5
Date: Tue, 6 Dec 2022 12:38:36 +0000

Dear all,

I believe we just stumbled upon one of the key differences between sed 4.2.2 on 
CentOS 7 and sed 4.5 on RedHat 8.

We found out some time ago that one of our application errors out when fed some 
XML file containing incorrect date formats, e.g different from 
“YYYY-MM-DDTHH:MM:SS”

For some unknown reason, the seconds get truncated from the date, leading to 
some error further down the line.

The workaround we are trying to put in place with sed is:

1/  find those occurrences of bad date format in the XML file, e.g: 
<EventDateTime>2021-08-17T06:06</EventDateTime>

2/ prepend each occurrence with “:00” (the missing seconds), e.g: 
<EventDateTime>2021-08-17T06:06:00</EventDateTime>

The regular expression we use reads as follows:

sed -i 
'/[0-9/][0-9/][0-9/][0-9/]-[0-9/][0-9/]-[0-9/][0-9/]T[0-9/][0-9/]:[0-9/][ 
0-9/]</ 
s/[0-9/][0-9/][0-9/][0-9/]-[0-9/][0-9/]-[0-9/][0-9/]T[0-9/][0-9/]:[0-9/][0-9/]/&:00/g'
 somefile.xml

It’s running just fine on our development environment (sed 4.2.2 on CentOS 7), 
but fails on RedHat 8 where a more recent version of sed is installed (4.5). It 
looks like as if the regular expression no longer works the same, and matches 
large chunks of the XML file instead of just the erroneous date.

What would be in your opinion the right command to use with sed 4.5 on RedHat 8 
?

Thank you all in advance for your help.

Best regards

Samuel
Ce message et toutes les pièces jointes (ci-après le "message") sont établis à 
l’intention exclusive des destinataires désignés. Il contient des informations 
confidentielles et pouvant être protégé par le secret professionnel. Si vous 
recevez ce message par erreur, merci d'en avertir immédiatement l'expéditeur et 
de détruire le message. Toute utilisation de ce message non conforme à sa 
destination, toute diffusion ou toute publication, totale ou partielle, est 
interdite, sauf autorisation expresse de l’émetteur. L'internet ne garantissant 
pas l'intégrité de ce message lors de son acheminement, Atos (et ses filiales) 
décline(nt) toute responsabilité au titre de son contenu. Bien que ce message 
ait fait l’objet d’un traitement anti-virus lors de son envoi, l’émetteur ne 
peut garantir l’absence totale de logiciels malveillants dans son contenu et ne 
pourrait être tenu pour responsable des dommages engendrés par la transmission 
de l’un d’eux.

This message and any attachments (the "message") are intended solely for the 
addressee(s). It contains confidential information, that may be privileged. If 
you receive this message in error, please notify the sender immediately and 
delete the message. Any use of the message in violation of its purpose, any 
dissemination or disclosure, either wholly or partially is strictly prohibited, 
unless it has been explicitly authorized by the sender. As its integrity cannot 
be secured on the internet, Atos and its subsidiaries decline any liability for 
the content of this message. Although the sender endeavors to maintain a 
computer virus-free network, the sender does not warrant that this transmission 
is virus-free and will not be liable for any damages resulting from any virus 
transmitted.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]