I need to make a fairly simple regex find and replace query, but for some reason, I'm not hitting a character in my regex.
The dates are formatted like this:
DD-MM-YYYYY
This should find the dates, but I'm not sure where to put the ' - ' so the regex can find it:
\([0-9][0-9]\)\([0-9][0-9]\)\(20[0-9][0-9]\)
outside the () doesn't seem to work, inside either..
- isn't a special character, to the best of my knowledge, can anyone give me a hint?
Date flipping
Moderators: AmigoJack, bbadmin, helios, MudGuard
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
If you use Posix regular expression syntax your regexes will be easier to read:
([0-9][0-9])([0-9][0-9])(20[0-9][0-9])
and you can now readily see where the hyphens go:
([0-9][0-9])-([0-9][0-9])-(20[0-9][0-9])
or
([0-9]{2})-([0-9]{2})-(20[0-9]{2})
If you want to change these dates to ISO format, use
With Posix syntax your regex becomesConfigure | Preferences | Editor
[X] Use POSIX regular expression syntax
([0-9][0-9])([0-9][0-9])(20[0-9][0-9])
and you can now readily see where the hyphens go:
([0-9][0-9])-([0-9][0-9])-(20[0-9][0-9])
or
([0-9]{2})-([0-9]{2})-(20[0-9]{2})
If you want to change these dates to ISO format, use
Find what: ([0-9]{2})-([0-9]{2})-(20[0-9]{2})
Replace with: \3-\2-\1
[X] Regular expression
-
nickw
- Posts: 4
- Joined: Fri Oct 26, 2007 3:28 pm
I dunno, I guess I'm doing something incorrectly, I've made sure that the Posix Regular expression button is selected, but I'm still unable to find the date..
0.0527000000,,317033*****,25-09-2007,09:40:32,261
0.0489000000,,39338******,05-09-2007,14:53:41,15
0.0789000000,,39347******,01-09-2007,09:55:53,25
0.1173000000,,39335******,05-09-2007,15:11:10,36
(stars for privacy purposes)..
([0-9]{2})-([0-9]{2})-(20[0-9]{2})
finds nothing, text and regular expression are selected, Match case is not...
0.0527000000,,317033*****,25-09-2007,09:40:32,261
0.0489000000,,39338******,05-09-2007,14:53:41,15
0.0789000000,,39347******,01-09-2007,09:55:53,25
0.1173000000,,39335******,05-09-2007,15:11:10,36
(stars for privacy purposes)..
([0-9]{2})-([0-9]{2})-(20[0-9]{2})
finds nothing, text and regular expression are selected, Match case is not...
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm