Regular Expressions Timestamp and Replace

General discussions about Advanced Find and Replace
Post Reply
aayjay
Posts: 4
Joined: Fri Jul 13, 2007 1:49 pm
Location: Scotland

Regular Expressions Timestamp and Replace

Post by aayjay » 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
aayjay666.bebo.com

aayjay
Posts: 4
Joined: Fri Jul 13, 2007 1:49 pm
Location: Scotland

Post by aayjay » Fri Jul 13, 2007 2:43 pm

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?

AJ
aayjay666.bebo.com

Abacre
Site Admin
Posts: 1201
Joined: Mon Jan 31, 2005 5:32 pm
Contact:

Post by Abacre » Fri Jul 13, 2007 3:47 pm

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).
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

aayjay
Posts: 4
Joined: Fri Jul 13, 2007 1:49 pm
Location: Scotland

Post by aayjay » Fri Jul 13, 2007 3:49 pm

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.

Cheers,
AJ
aayjay666.bebo.com

Abacre
Site Admin
Posts: 1201
Joined: Mon Jan 31, 2005 5:32 pm
Contact:

Post by Abacre » Fri Jul 13, 2007 3:51 pm

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.
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

aayjay
Posts: 4
Joined: Fri Jul 13, 2007 1:49 pm
Location: Scotland

Re: Regular Expressions Timestamp and Replace

Post by aayjay » Sun Jul 15, 2007 11:52 am

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 :(

Cheers!
AJ
aayjay666.bebo.com

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests