[TF] "north east west" -> "NEW" ?
Brought to you by:
kenkeys
|
From: johans at stack.nl (J. v. Selst) - 2003-03-12 23:50:39
|
Phil Gregory wrote:
> In Perl, it'd be a simple 's/\b(\w)\w*\W+/$1/g', but tf does not seem
> blessed with such things, and I'm at a loss as to a good way to proceed.
> Any suggestions?
To replace a string of words by the first letter of every word, you can
do something like:
/def lfirst =
/let s=%;\
/while ({#}) \
/let s=$[strcat(s, substr({1}, 0, 1))]%;\
/shift%;\
/done%;\
/result s
This obviously has nothing todo with PCRE's anymore; and I don't think
TF 4 has an option to do regular expression substitutions like sed or
perl will offer you.
The mysterious TF 5 and the package at
http://tf-macros.sourceforge.net/packages/ do support PCRE-like
matching, but I'm not sure if these offer substitutions in a similar
way as well...
Ciao,
Johan
|