Hi Everyone,

Can u please guide me how do i replace the string

String a="FirstName & LAstName [abc]"; by
String b="FirstName, LAstName [abc]";


String Result="<aaaa> FirstName & LAstName [abc] </bbb>"
String Result=Result.replaceAll(a,b);

The above two lines are not working coz of square brackets in the String. Can u please provide me an alternate solution

That's a rather odd replacement you're making, but you can do it by escaping the square brackets like so

String a="FirstName & LAstName \\[abc\\]";
        String b="FirstName, LAstName \\[abc\\]";

They are being interpreted as a regular expression construct instead of normal characters.

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.