Connecting Tech Pros Worldwide Forums | Help | Site Map

need help on string matching and tranlastion

Newbie
 
Join Date: Feb 2009
Posts: 1
#1: Feb 25 '09
dear sir,
i need help in perl program where i want to search a string from paragraph and to convert all the letters in para to X except that string... in this program i have used string matching (regular expresion). i have use like this

Expand|Select|Wrap|Line Numbers
  1. if ($para =~ s/$string/XXXXX/ig) {
  2.  
  3. open MYFILE, ">result.txt";
  4. select MYFILE;
  5.  
  6. print $para ;
  7. print "\n\n";
but here the string will be changing to 'XXXXX'. i need to convert the other letters..pls help anyone... thanks in advance

KevinADC's Avatar
Expert
 
Join Date: Jan 2007
Location: Southern California USA
Posts: 4,091
#2: Feb 25 '09

re: need help on string matching and tranlastion


Well, you are telling the regexp to find $string and replace it with XXXXX so its no surprise thats what is happening. Post a before and after example of what you are trying to do and explain anything that is not clear.
Icecrack's Avatar
Expert
 
Join Date: Sep 2008
Location: Sydney, Australia
Posts: 173
#3: Feb 26 '09

re: need help on string matching and tranlastion


here is what i think you want else explain in more detail of what string your matching or why you are trying to XXXX out the rest.


Expand|Select|Wrap|Line Numbers
  1. if ($para !~ m/$string/ig)
  2. {
  3. $para =~ s/$para/XXXXX/ig;
  4. }
  5. elsif ($para =~ m/.$string./ig)
  6. {
  7. print "$para \n\n";
  8. }
Reply

Tags
string match