Alan Fry wrote:
> I hope this is helpful,
>
> Alan Fry
Yes, Alan, I T I S helpful! ("You are my very personal hero"
or s.th. like that my son would have said in such a case :-) )
Your and Nobumis programm gave me the thought of trying a
little step ahead:
With your extracting of style places we can
**search and replace within styled text**; e.g. within
FileMaker (which has no editor-like functions for replacing).
After each replacing loop within the TEXT we have to recalculate the STYLES.
This could be done somewhat like this:
#!perl
#The text example:
$_ = " foo-bar foo-bar foo-bar foo-bar foo-bar foo-bar foo-bar";
$search = "foo-bar";
$replace = "foobar";
$diff = length($search)-length($replace);
$diff_offset = 3; ## will be needed if styles change within a changed word
print "\$_: $_ string-diff.: $diff";
## For the sake of inexpensive demonstration
## style places are simulated by word endings:
while (m,r\b,g) { push @styl1, pos }
while (m,$search,g) { push @found, pos }
print "\nstyl1: @styl1"; ## f o u n d "styles" before replacing
print "\nfound: @found\n"; ## where each search string ends
@stylC = @styl1;
for ($j=$#found; $j>=0; $j--) {
$i = $#stylC;
while ($stylC[$i] >= $found[$j] && $i>=0 ) {
$stylC[$i] -= $diff;
$i-- ; } }
s,$search,$replace,g;
print "\n\$_: $_\n";
while (m,r\b,g) { push @styl2, pos }
while (m,$replace,g) { push @replace, pos }
print "\nstyl2: @styl2"; ## "styles" f o u n d after replacing
print "\nstylC: @stylC"; ## c a l c u l a t e d "styles"
__END__
Finding and replacing could be outsourced from
Tex-Edit to MacPerl; this means: Some more thourough scripting,
and we can use RegEx’ within Tex-Edit, FileMaker, ... !
a New Age dawning :-) :-)
Detlef