How to replace repeated substring in other string?

Reply

Join Date: Sep 2005
Posts: 17
Reputation: perlsu is an unknown quantity at this point 
Solved Threads: 0
perlsu perlsu is offline Offline
Newbie Poster

How to replace repeated substring in other string?

 
0
  #1
Sep 14th, 2005
Hi

I want to replace "ta,at,an,bc" in main string {ta,at,an,bc,ta,at,an,bc,ta,at,an,bc,ef,ta,at,an,bc,ta,at,an,bc" with (ta at an bc)*.The result array should be "(ta at an bc)*,e,(ta at an bc)*". Can anyone give me some hint? Thanks in advance.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 216
Reputation: hooknc is an unknown quantity at this point 
Solved Threads: 8
hooknc hooknc is offline Offline
Posting Whiz in Training

Re: How to replace repeated substring in other string?

 
0
  #2
Sep 14th, 2005
Look at the java.lang.String class' Java API doc through google. You should find what you're looking for.

Regards,

Nate
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: How to replace repeated substring in other string?

 
0
  #3
Sep 14th, 2005
Have a counter variable that keeps track of the current index, iterate and find some new junk.
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 55
Reputation: NPH is an unknown quantity at this point 
Solved Threads: 1
NPH NPH is offline Offline
Junior Poster in Training

Re: How to replace repeated substring in other string?

 
0
  #4
Sep 14th, 2005
You can use the String classes replaceAll method. Here is an example:

  1. String str = "Hello blank";
  2. String newStr = str.replaceAll("blank", "Jim") ;
  3.  
  4. System.out.println(newStr); //prints "Hello Jim"
For more help, www.NeedProgrammingHelp.com
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC