need help on string matching and tranlastion

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sajancr
    New Member
    • Feb 2009
    • 1

    #1

    need help on string matching and tranlastion

    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

    Code:
    if ($para =~ s/$string/XXXXX/ig) {
    
    open MYFILE, ">result.txt";
    select MYFILE;
    
    print $para ;
    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
    Last edited by eWish; Feb 26 '09, 01:45 PM. Reason: Please use the code tags
  • KevinADC
    Recognized Expert Specialist
    • Jan 2007
    • 4092

    #2
    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.

    Comment

    • Icecrack
      Recognized Expert New Member
      • Sep 2008
      • 174

      #3
      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.


      Code:
      if ($para !~ m/$string/ig)
      {
      $para =~ s/$para/XXXXX/ig;
      }
      elsif ($para =~ m/.$string./ig)
      {
      print "$para \n\n";
      }

      Comment

      Working...