944,004 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 15077
  • Java RSS
Sep 14th, 2005
0

How to replace repeated substring in other string?

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
perlsu is offline Offline
17 posts
since Sep 2005
Sep 14th, 2005
0

Re: How to replace repeated substring in other string?

Look at the java.lang.String class' Java API doc through google. You should find what you're looking for.

Regards,

Nate
Reputation Points: 11
Solved Threads: 8
Posting Whiz in Training
hooknc is offline Offline
216 posts
since Aug 2005
Sep 14th, 2005
0

Re: How to replace repeated substring in other string?

Have a counter variable that keeps track of the current index, iterate and find some new junk.
Reputation Points: 113
Solved Threads: 19
Postaholic
server_crash is offline Offline
2,108 posts
since Jun 2004
Sep 14th, 2005
0

Re: How to replace repeated substring in other string?

You can use the String classes replaceAll method. Here is an example:

Java Syntax (Toggle Plain Text)
  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
NPH
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
NPH is offline Offline
55 posts
since May 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Two basic java questions
Next Thread in Java Forum Timeline: JPanel and putting a Background GIF pic...NOT WORKING





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC