[ic] Filter ul

John Young john_young at sonic.net
Wed Jul 16 16:14:16 EDT 2003

Trentt Cramer wrote:
> Is there a standard filter that converts (form) names to Uppercase/Lowercase
> (1st char uc, rest lc)?

Filter "namecase" is close, but it looks like it only converts when the 
string starts with an uppercase letter.
Perhaps instead of:
     $val =~ s/([A-Z]\w+)/\L\u$1/g;
maybe it should say:
     $val =~ s/([A-Z][a-z]\w+)/\L\u$1/g;

Anyway, in case I've missed something, you can find all the filters and what
they do simply by looking in two places:

~interch/lib/Vend/Interpolate.pm  - look around line# 800 for "%Filter = ("
~interch/code/Filter              - which is also where you can install 
custom filters

The documentation lists filters, but the two locations above are the 
actual sources.

If you have to write your own, you can try something like creating
~interch/code/Filter/titlecase.filter containing the following:

CodeDef titlecase Filter
CodeDef titlecase Routine <<EOR
sub {
	my $val = shift;
	$val =~ s/(\w+)/\u\L$1/g;
	return $val;

To use it, then, you would need to restart Interchange.  I haven't 
tested the
code above, but basically the regex works like this:
\w+   matches one or more "word" characters
()    "remembers" that word through back-referencing (later referred to 
with $1)
\u    uppercase the first letter
\L    lowercase the rest of the word
$1    the word from the back-reference

John Young

More information about the interchange-users mailing list