|
Posted by RK_78 on February 18, 2008, 9:34 am
Please log in for more thread options > Is there a way in Regular Expressions to convert a string that is all
> in upper case - and replace it with it's lower case equivalent?
>
> I can do something like ([A-Z][A-Z]+\x?) to match any given word and
> reference it as , however without using programming language lcase
> or LOWER functions on it - how can I use reg ex to convert the text to
> it's lower case equivalent??
>
> Thanks - (I use coldfusion but the regular expression syntax is
> similar)
Hi Penny ;
Try This
my $InFile=$ARGV[0] || die("**ERROR** -> Usage: $0 InputFile
OutputFile \n");
my $OutFile=$ARGV[1] || die("**ERROR** -> Usage: $0 InputFile
OutputFile \n");
open(INFILE,"< $InFile") || die "cannot open $InFile : $!"; # $!
Stores the error message
open(OUTFILE,"> $OutFile") || die "cannot open $OutFile : $!";
my $line;
while ($line=<INFILE>) {
$line =~ tr/A-Z/a-z/;
printf(OUTFILE $line);
}
close(INFILE);
close(OUTFILE);
The key point here is the tr/// transliteration operator.
Better ideas folks ?
Riad.
|