> CREATE FUNCTION remspace(TEXT) RETURNS TEXT AS '
> return map { s/\s*// } @_;
> ' LANGUAGE 'plperl' WITH (isstrict);
This may or may not do what you're looking for.
s/\s*// or s/\s+// removes only the spaces from the first occurrence to
the before first non-space character.
To remove all the spaces from the string then:
s/\s+//g
To strip or trim the beginning and ending spaces.
s/^\s+//
s/\s+$//
Tom
> > "Duncan Adams (DNS)" <duncan.adams@vcontractor.co.za> writes:
> >
> > I'm not much of a Perl hacker, but even I can see that this is not good
> > Perl. You need a semicolon to finish the return statement, and I think
> > you want to manipulate the first element of the @_ array, not the whole
> > array. So something like
> >
> > CREATE or REPLACE FUNCTION remspace(TEXT) RETURN TEXT AS '
> > $_[0] =~ s/\s*//;
> > return $_[0];
> > ' LANGUAGE 'plperl';
> >
> > would probably do what you want.
> >
> > I'd recommend getting hold of a book about Perl.