Hi Jim,

rather than re-invent the wheel I would prefer if you could fix this regex
I believe it covers all invalid characters one would encounter

s/[<sup>\w\&amp;%'[EMAIL PROTECTED](\)&amp;_\</sup>\+,\.=\[\]]//g;

I would then use it as a general purpose regex for validating filenames.

Regards
Colin

  
> Hi all,

Hi

> 
> create a filename.
> 
> I firstly need to remove any invalid characters (including spaces)

What do you consider invalid chars? Do you want just alpha cars? 

> 
> $filename = 'News & events';
> $filename =~ 
> s/[<sup>\w\&amp;%'[EMAIL PROTECTED](\)&amp;_\</sup>\+,\.=\[\]]//g; 
> 
> then convert it to lowercase.

$filename =~ s/[^A-Za-z]//g; #use only alpha chars
print lc($filename); # convert to lower case

# or if you want to strip out non printing (control) chars:
$filename = " News \r \n \x01 even ts";
$filename =~ s/[[:cntrl:]]//g;
$filename =~ s/\s//g;
print lc($filename);

That help at all?
Jim







---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.745 / Virus Database: 497 - Release Date: 8/27/2004
 


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




This E-Mail is intended only for the addressee. Its use is limited to that
intended by the author at the time and it is not to be distributed without the
author's consent. Unless otherwise stated, the State of Queensland accepts no
liability for the contents of this E-Mail except where subsequently confirmed in
writing. The opinions expressed in this E-Mail are those of the author and do
not necessarily represent the views of the State of Queensland. This E-Mail is
confidential and may be subject to a claim of legal privilege.

If you have received this E-Mail in error, please notify the author and delete this 
message immediately.


--
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