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.

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

Regards,

Nate

Have a counter variable that keeps track of the current index, iterate and find some new junk.

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

String str = "Hello blank";
String newStr = str.replaceAll("blank", "Jim") ;

System.out.println(newStr); //prints "Hello Jim"

For more help, www.NeedProgrammingHelp.com

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.