>>>>> geoffhazel <
geoff...@gmail.com> writes:
[Cross-posting to news:comp.editors and setting Followup-To:
there, for the question is hardly Unix-specific.]
> I have a file like this
> 02/1/2012
> 02/2/2012
> 02/3/2012
> 03/1/2012
> 03/2/2012
> 03/3/2012
> I want it to be 02/01/2012 and so forth, MM/DD/YYYY format with extra
> 0's as placeholders.
[...]
> I can find the patterns with /./ but how do I preserve the characters
> that are there? I seem to recall there's a way to specify those with
> some regex but can't recall the details.
One can reference a \(\)-group from within the s-command's
replacement text with \1 ... \9, like:
s;/\([0-9]/\);/0\1;
--
FSF associate member #7257