[Ssh-sftp-perl-users] Help need in Perl Script to delete special character
Brought to you by:
dbrobins
From: Vikas P. <vik...@ya...> - 2008-08-21 09:49:50
|
Hello All I am having a perl script that is used to delete all the special character but now the condtion is that if the last character is Alphabet, or star(*) or Questionmark(?) or number(0-9) then there shuld not be deletion of special characters. e.g if we have ab++ then output shub be AB if we have a++b then output shuld be A++B if there are all special character then all needs to be deleted. I have script that is used ot delete all special character but not fulfuling the condtion. IF Anyone can help it willl be great. Thanks in Advance This script deletes all the special character and i want it shuld not delete the charachters which are in between. #!/usr/bin/env perl $hsnr_vikas=&hsnr2norm("a-b1-1"); print "\n $hsnr_vikas\n"; sub hsnr2norm { local($hsnr)=@_; $hsnr=uc($hsnr); $hsnr=~s/[\-\"\'\!\§\$\%\&\/\.\'\´\`(\s+)\|]/-/g; $hsnr=~s/[\;\,\:\#\_\(\)\=\`\´\+\_\<\>\@\[\]\{\}\\\~]/-/g; $hsnr=~s/[\\\\\\\¦\÷\³\²\\^\¿\¶\±\¹\¥]/-/g; my $pos = 0; while ( $pos < length($hsnr) ) { $zeichen = substr( $hsnr,$pos,1 ); if ($zeichen =~ m/[0-9A-Z*?äàáâãäåæçèéêëìíîïñöòóôõöøüùúûüý]/) {$pos++; } else { $hsnr =~s/$zeichen//g; } } $hsnr; } |