Change urlize function so that it removes all leading and trailing whitespace from the string.
This commit is contained in:
parent
c7a5183369
commit
2b84feb29f
1 changed files with 8 additions and 6 deletions
|
|
@ -81,12 +81,14 @@ sub unescape {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub urlize {
|
||||
my ($title);
|
||||
$title = lc($_[0]);
|
||||
$title =~ s/ /_/g;
|
||||
$title =~ s/\.$//g;
|
||||
$title =~ s/[^a-z0-9\-\.\_]//g;
|
||||
return $title;
|
||||
my ($value);
|
||||
$value = lc($_[0]); #lower cases whole string
|
||||
$value =~ s/\W+$//g; #removes trailing whitespace
|
||||
$value =~ s/^\W+//g; #removes leading whitespace
|
||||
$value =~ s/ /_/g; #replaces whitespace with underscores
|
||||
$value =~ s/\.$//g; #removes trailing period
|
||||
$value =~ s/[^a-z0-9\-\.\_]//g; #removes all funky characters
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue