Regex to process multiple entries for a digital signature


I have the regex and corresponding match output here :

Which matches IP and time stamp for all entries currently but I also want the hexadecimal value for identification.

For ex for below Input string:

IDVal 4273E6D162ED2717A1CF4207A254004CD3F5307B
Posted 2022-12-28 07:35:55
Status 2022-12-28 08:10:11
Entry 2022-12-28 11:10:30
Entry 2022-12-28 13:10:30
Entry 2022-12-28 12:56:30
Entry 2022-12-28 12:35:30

Output should match/capture :

4273E6D162ED2717A1CF4207A254004CD3F5307B 2022-12-28 11:10:30 2022-12-28 13:10:30 2022-12-28 12:56:30 2022-12-28 12:35:30

I tried this regex :

(?s)(\b[A-F\d]{40}\b).*?(\b((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b).?(\b\d{4}(-\d{2}){2} (\d{2}:){2}\d{2}\b)

It then returns the hexadecimal digital signature, but then it only returns the first Entry and doesn’t returns all the corresponding entries.


You can start building your query from the back.

Case 1: 4273E6D162ED2717A1CF4207A254004CD3F5307B from the back match:

  • multiple alphanumerical characters of length 3+ (3+ otherwise will match seconds of next rows): [\d\w]{3}[\d\w]+

Case 2: 2022-12-28 12:56:30 from the back match:

  • a set of numbers and ":": [\d:]+,
  • a space,
  • a set of numbers and "-": [\d-]+
  • a space,
  • a set of numbers and ".": [\d\.]+

Final regex:

"([\d\w]{3}[\d\w]+|[\d\.]+ [\d-]+ [\d:]+)$"

Tested on:

Does it work for you?

Answered By – lemon

Answer Checked By – Terry (GoLangFix Volunteer)

Leave a Reply

Your email address will not be published.