Regular Expressions Timestamp and Replace
Posted: Fri Jul 13, 2007 1:54 pm
Hi,
I am currently testing your software for an internet business project. I need to basically use regular expressions to search for a specific format of text and replace this with another format.
The format is this:
7/9/2007 6:00:01 PM.121
The problem is the milliseconds are being appended after the PM. I need to perform an advanced search and replace such that the format for the above example would be:
7/9/2007 6:00:01.121 PM
My expression : [0-9][\:][0-9][0-9][\:][0-9][0-9][\s][A,P][M][\.][0-9][0-9][0-9]
This will find the timestamps in the logs im working with, however can i use another expression to rearrange these. I tried replace with :
[0-9][\:][0-9][0-9][\:][0-9][0-9][\.][0-9][0-9][0-9][\s][A,P][M]
However this did not work and after looking at the forums here it seems you can use $1 in the replace as some kind of placeholder.
Please advise
Kind Regards,
AJ
I am currently testing your software for an internet business project. I need to basically use regular expressions to search for a specific format of text and replace this with another format.
The format is this:
7/9/2007 6:00:01 PM.121
The problem is the milliseconds are being appended after the PM. I need to perform an advanced search and replace such that the format for the above example would be:
7/9/2007 6:00:01.121 PM
My expression : [0-9][\:][0-9][0-9][\:][0-9][0-9][\s][A,P][M][\.][0-9][0-9][0-9]
This will find the timestamps in the logs im working with, however can i use another expression to rearrange these. I tried replace with :
[0-9][\:][0-9][0-9][\:][0-9][0-9][\.][0-9][0-9][0-9][\s][A,P][M]
However this did not work and after looking at the forums here it seems you can use $1 in the replace as some kind of placeholder.
Please advise
Kind Regards,
AJ