B
Bill H
Can someone point me to some docs on how I would do this without
iterating over the whole string (pattern matching?):
$original = "a malformed%string/containi\"ng characters I don'~t
want! ...";
$filter = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-_";
$new = &fix($original);
$new would now equal:
amalformedstringcontainingcharactersidontwant
sub fix
{
my $o = shift;
my $r = "";
my $i = 0;
for($i = 0;$i < length($o);$i++)
{
if(index($filter,uc(substr($o,$i,1))) != -1){$r .= substr($o,$i,1);}
}
return($r);
}
I just typed this in to give you the gist of what I want to do so if
there are errors it is in my typing.
Bill H
iterating over the whole string (pattern matching?):
$original = "a malformed%string/containi\"ng characters I don'~t
want! ...";
$filter = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-_";
$new = &fix($original);
$new would now equal:
amalformedstringcontainingcharactersidontwant
sub fix
{
my $o = shift;
my $r = "";
my $i = 0;
for($i = 0;$i < length($o);$i++)
{
if(index($filter,uc(substr($o,$i,1))) != -1){$r .= substr($o,$i,1);}
}
return($r);
}
I just typed this in to give you the gist of what I want to do so if
there are errors it is in my typing.
Bill H