471,888 Members | 1,839 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,888 software developers and data experts.

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

Expand|Select|Wrap|Line Numbers
  1. if ($para =~ s/$string/XXXXX/ig) {
  3. open MYFILE, ">result.txt";
  4. select MYFILE;
  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
Feb 25 '09 #1
2 2377
4,059 Expert 2GB
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.
Feb 25 '09 #2
174 Expert 100+
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. }
Feb 26 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Joh | last post: by
2 posts views Thread by s | last post: by
10 posts views Thread by javuchi | last post: by
2 posts views Thread by Rob | last post: by
reply views Thread by YellowAndGreen | last post: by
reply views Thread by zermasroor | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.