Replacing bracket ( “(” ) in java
May 1, 2010 Leave a comment
While doing my project I was facing this situation, which was solved as this:
public class ReplaceBracket { public static void main(String[] args) { String str=":-)"; String repStr=str.replaceAll("\\)","P"); System.out.println(str +" is replcaed to " +repStr); } }
public class ReplaceBracket
{
public static void main(String[] args)
{
String str=”:-)”;
String repStr=str.replaceAll(“\\)”,”P”);
System.out.println(str +” is replcaed to ” +repStr);
}
}
{
public static void main(String[] args)
{
String str=”:-)”;
String repStr=str.replaceAll(“\\)”,”P”);
System.out.println(str +” is replcaed to ” +repStr);
}
}
Here in this example, bracket is replaced by P.
Advertisements
Recent Comments