Page 1 of 1

Regular Expressions Timestamp and Replace

Posted: Fri Jul 13, 2007 1:54 pm
by aayjay

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 :

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,


Posted: Fri Jul 13, 2007 2:43 pm
by aayjay

Code: Select all

Search for: (.*)\:(.*)\:(.*)\s(.*)\.(\d{3})

Replace with: $1:$2:$3.$5 $4
This seems to work after some more hunting. However the application is hanging on me. I am on good hardware and the file im working with is 50mb txt and the application must change each line of text.

Perhaps working with smaller chunks at a time?


Posted: Fri Jul 13, 2007 3:47 pm
by Abacre
To correctly process all types of regular expressions the whole file is loaded into memory. Then the file is processed.
In future version we will develop new mode where the file is processed by small chunks (or line-by-line mode).

Posted: Fri Jul 13, 2007 3:49 pm
by aayjay
Thanks for the reply! :)

It's still churning away, ill maybe take my work laptop home and keep it running. The tool is fantastic, im just trying to bulk edit a lot of text.


Posted: Fri Jul 13, 2007 3:51 pm
by Abacre
Regular expressions are quite slow in comparison to lateral (string) replace operations. But keep AFR running. It will process your file.

BTW. Switch off Preview Mode:
See menu Action - Options - Preview - Use Preview option.

Collecting information for preview is also very time and memory consuming process. It may speed up the process in several times.

Re: Regular Expressions Timestamp and Replace

Posted: Sun Jul 15, 2007 11:52 am
by aayjay
Hey Roman,

Thanks for the speed up tips. I managed to get the first file done in 6 hours, then the next 2 files took appx 1 hour 30 each, even though they were the same size :) Using the batch replace and regular expressions i was able to rearrange over 100,000 timestamps ... something im very glad i didn't have to do manually ;)

Thanks for your excellent support and i will be recommending buying this software for anyone who needs this type of application. Just have to get damn approval from the higher uppers :(