Gossamer Forum
Quote Reply
Re: [Robert] Regex Help In reply to
Looks like a good approach, I dealt with something similar while I was trying to make some URL-escaping for LinksSQL.
I ended up with:

Code:
sub superlc {
my $return = shift;
$return =~ tr///;
$return = lc($return);
return $return;
}

Code:
sub URL_escape {
my $return = shift;
my %umlaute = (
"" => "ae",
"" => "Ae",
"" => "ue",
"" => "Ue",
"" => "oe",
"" => "Oe",
"" => "ss",
"" => "a",
"" => "a",
"" => "a",
"" => "a",
"" => "a",
"" => "a",
"" => "a",
"" => "a",
"" => "c",
"" => "c",
"" => "e",
"" => "e",
"" => "e",
"" => "e",
"" => "e",
"" => "e",
"" => "e",
"" => "e",
"" => "i",
"" => "i",
"" => "i",
"" => "i",
"" => "o",
"" => "o",
"" => "oe",
"" => "oe",
"" => "u",
"" => "u",
"" => "u",
"" => "u",
"" => "y",
"" => "y",
);
my $umlautkeys = join ("|", keys(%umlaute));
$return =~ s/($umlautkeys)/$umlaute{$1}/g;
$return =~ s///\//g;
$return =~ s/'|#|\||\s|\t|\r|\n|\/|;|"|&/-/g;
while (substr($return,0,1) eq "-") {
substr($return, 0, 1) = "";
}
while (substr($return,-1,1) eq "-") {
chop($return);
}
$return = lc($return);
$return =~ s/([^\w\-.:,!~*'()])/sprintf("%%%02X",ord($1))/eg;
$return =~ s/-{1,}/-/g;
return $return;
}

Maybe some inspiration for you.

Regards

n||i||k||o
Subject Author Views Date
Thread Regex Help Robert 5411 Oct 13, 2017, 4:13 AM
Thread Re: [Robert] Regex Help
Robert 5287 Oct 13, 2017, 4:42 AM
Post Re: [Robert] Regex Help
el noe 5271 Oct 13, 2017, 5:23 AM
Thread Re: [Robert] Regex Help
Andy 5268 Oct 13, 2017, 8:56 AM
Thread Re: [Andy] Regex Help
Robert 5266 Oct 13, 2017, 9:06 AM
Post Re: [Robert] Regex Help
Robert 4858 Dec 9, 2017, 2:57 PM