Jim Schueckler schreef:

> I need to remove all characters from a string except 'a'..'z',
> 'A'..'Z', and '0'..'9'.
>
> Could somebody please tell me the magicWords for:
>    $newstring = magicWords($oldstring);    ???
>
> I am absolutely new to Perl and regular expressions, so please don't
> assume I know anything that everybody else knows. :-)

What makes you think that a regular expression is needed or even the
best solution?

See `perldoc -f tr`, which will tell you to read on in `perldoc perlop`.
Search for tr/ at the perldoc-prompt to jump to the documentation of
tr///.

You might actually be looking for this:

  (my $newstring = $oldstring) =~ tr/0-9A-Za-z/ /cds;

which replaces runs of non-alphanumeric characters with a single space.
See also `man strings`.

-- 
Affijn, Ruud

"Gewoon is een tijger."



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to