Skip to content

Instantly share code, notes, and snippets.

Created August 20, 2009 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/171194 to your computer and use it in GitHub Desktop.
Save anonymous/171194 to your computer and use it in GitHub Desktop.
sub _filterKeywords {
my $self = shift;
my $keywords = shift;
$keywords = WebGUI::HTML::filter($keywords, "all");
# split into 'words'. Ideographic characters are treated
# as distinct words. Everything else is space delimted
my @words = split /\s*|(\p{Ideographic})/, $text;
# remove punctuation characters at the start and end of each word.
my @filteredWords = ();
WORD: for my $word ( @words ) {
next WORD unless defined $word
&& $word ne '';
$word =~ s/\A\p{isPunct}//;
$word =~ s/\p{isPunct}\z//;
push @filteredWords, $word;
}
$keywords = join q{ }, @words;
return $keywords;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment