At 23:30 +0100 on 11/01/2011, John Delacour wrote about Re: In a
TextFactory line how to replace multiple instances:
At 18:39 -0400 1/11/11, Ronald J Kimball wrote:
Perhaps you meant something like this:
#! /usr/bin/perl
use strict;
my $switch_on;
while (<>) {
$switch_on = 1 if /<caption>/;
$switch_on = 0 if $switch_on && s/td>/th>/g;
print;
}
__END__
This has the advantage that only the first row after a <caption> will
use THs. All subsequent lines (if any) will stay as TDs. This way you
have a Table Heading row followed by Table Data rows.
Yes, except that I'd write 'and' and not '&&', not being much of a golfer.
You could implement that much more succinctly using Perl's flip-flop
operator:
#! /usr/bin/perl
use strict;
while (<>) {
/<caption>/ .. s/td>/th>/g;
print;
}
Very nice.
--
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
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 "[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>