Working with 2014-06-14-1506p here is a helpful Regexp to reorder it
Using a most excellent tool from (den4b called Renamer) - one of the few tools I happily purchased and want to promote it!
The regular expression to rearrange the date (helpful for date-stamping files) is:
(.*)([0-9]{4}[-_]{0,1}[0-1][0-9][-_]{0,1}[0-3][0-9])[-_]{0,1}([0-2][[0-9][0-5][0-9][a,p]{0,1}){0,1}[-]{0,1}(.*)
---1-----------------------------------------------2_________-------------------------------------3________----4
then it can be easily reordered:
$2-$3-$1-$4
For those of you unfamiliar with REGEX or ReGularEXpressions- it breaks down like this:
The regular expression to rearrange the date (helpful for date-stamping files) is:
(.*)([0-9]{4}[-_]{0,1}[0-1][0-9][-_]{0,1}[0-3][0-9])[-_]{0,1}([0-2][[0-9][0-5][0-9][a,p]{0,1}){0,1}[-]{0,1}(.*)
---1-----------------------------------------------2_________-------------------------------------3________----4
then it can be easily reordered:
$2-$3-$1-$4
For those of you unfamiliar with REGEX or ReGularEXpressions- it breaks down like this:
- (.*) = $1
- will match zero or more of any characters
- By enclosing it in parenthesis () it becomes a sub expression.
- Since it is the first subexpression it can be referenced to be reordered with $1 in Renamer.
- ( = left parenthesis start of the second expression $2 for the year-month-day
- left parenthesis is the the start of the next expression to Capture. If the parenthesis weren't there the characters would match and be lost
- [0-9]{4} for the year 0000 through 9999
- Square brackets [ ] enclose a set of characters for reference.
- 0-9 inside the brackets species a range of all characters 0 through 9
- {4} Curled brackets indicate the number of characters to match in the previous expression.
- By combining [0-9]{4} means 4 numbers, zero through nine- perfect for a date 2014
- alternatively ([1-2]{1}[0-9]{3}) should cover the last century 1000 through 29
- [-_]{0,1} is for a literal dash or underscore character - zero or one of
- [0-1][0-9] for the month
- alternatively [0-1]{0,1}[0-9] would allow for 06 or 6 for the month
- [-_]{0,1} is for a literal dash or underscore character
- [0-3][0-9] for the day 01 through 39
- alternatively [0-3]{0,1}[0-9] would allow for a single digit day
- ) = right parenthesis END of the second expression $2 for the year-month-day
- [-_]{0,1} is for a literal dash or underscore character - zero or one of
- ( = left parenthesis start of the third expression $3
- [0-2][0-9][0-5][0-9] = for time 0000 through 2959 (Covers through 2399 24 hour clock)
- [am,a,p,pm]{0,1} = zero or one of a, am, p, pm for am pm--There is a glitch here I cannot figure out how to extend so it has the matching for am|a|pm|p - since the letters are the same it will not match the characters
- ){0,1} = Right parenthesis END of the third expression $3 {0,1} means zero or one of these can exist
- [-_]{0,1} is for a literal dash or underscore character - zero or one of
- (.*) = $4 the 4th expression- the remainder (zero or more) of the remaining characters- in case the match is in front of the expression
Comments
Post a Comment