regEx in UltraEdit

This entry was posted by on Thursday, 10 December, 2009 at

Problem:

A list with http connection speeds
01:00:20 (49.79 KB/s) - `logs/http-mon-arl.txt' saved [1000000/1000000]
01:00:21 (48.56 KB/s) - `logs/http-mon-arl.txt' saved [1000000/1000000]
01:00:28 (361.03 KB/s) - `logs/http-mon-arl.txt' saved [1000000/1000000]

Now the KB/s should be added with a leading space if it’s 2-digit

UltraEdit speaks its own dialect of regular expressions but i prefer the pearl-style

So replace

\((\d\d\.)

with

( \1

Explaination:

( goups matches for backreferences, so it’s masked as \(
Start grouping by (
\d\d – 2 digits
. metachar matches anything so its masked as \.
) closes the backreference-group

Replaced by a simple ( and the referenced group \1 within the unmasked  ()
01:00:20 ( 49.79 KB/s) - `logs/http-mon-arl.txt' saved [1000000/1000000]
01:00:21 ( 48.56 KB/s) - `logs/http-mon-arl.txt' saved [1000000/1000000]
01:00:28 (361.03 KB/s) - `logs/http-mon-arl.txt' saved [1000000/1000000


Leave a Reply