At 10:23 +0200 18/08/2011, Mark wrote:

Does anybody know if there's a way to enter today's date via search and replace? I have files with strings like this
<imported>2009-02-12</imported>
and I'm processing them with a text factory that does a lot of other stuff. I would like it to also change the whatever date in that tag into the date when I run the text factory.

The following text filter will do what you want. Whether it's possible to do it with some simple built-in function I don't know.


#!/usr/local/bin/perl
use strict;
my @date = localtime;
my @datearray;
$date[5] += 1900;
for (5,4,3) {
  push @datearray, sprintf '%.2d', $date[$_]
}
my $date = join "-", @datearray;
while (<>) {
  s~(<imported>)\d\d\d\d\-\d\d\-\d\d(</imported>)~$1$date$2~g;
  print;
}


# JD

--
You received this message because you are subscribed to the "BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem, please email "supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>

Reply via email to