Hi and welcome!
dbareis wrote:My Expression so far is: %b(s/([0-9]+)-([0-9]+)-([0-9]+)/\3-\2-\1 \4/).%e
That gets it to: "2013-3-30 - Fred was here.txt", close but I want the month (3) padded to "03".
>>(I wish there were more examples)
>>If someone can explain why this doesn't work that would be great:
Some tips:
1) RegEx is a pattern matching system to take some parts to keep and maybe some others to drop.
So one would e.g. match parts of the file name, store them in backreference groups and reorder them in the output.
As you did. But there is no magic as conjure up additional parts out of nowhere.
There is no such things as "padding" per se. Just matching parts and use them for some operations. As Rémi did with his
first additional expression s/-(\d)-/-0\1-/g (match single digit between hyphens and replace with '0' and matched digit)
Then you can continue whit that first output as input for the reorder-expression of you.
2) Parentheses () can be used to store what is matched for later reuse by \1 and so on.
Those backreference groups are counted from left to right.
So s/([0-9]+)-([0-9]+)-([0-9]+ will provide three backreference groups,... but you use *four* references \3-\2-\1 \4
The \4 is to much, because not matched, and not needed either as Siren provide the unmatched part on its own.
3) Instead of [0-9] you can use the shorter \d
The character class [0-9] would be used as e.g. [1-3] to match 1,2 or 3 only.
But to match any digit out of 0,1,2,3...9 you can use just \d
So your expression could be written as s/(\d+)-(\d+)-(\d+)/\3-\2-\1
That you do not need to match the text too is because which regex engine is used,
and how Rémi has implemented that.
HTH?