String Replacement

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rsrinivasan
    New Member
    • Mar 2007
    • 221

    String Replacement

    Hi all,

    I need to replace double quotes in a string with some cahracter. Im getting the a product value from database. That product name is like this..

    sri"vas

    So i cant pass this value to anywhere..
    So i need to cahnge double quotes with some other character..


    My code is..

    prodName = prodName.replac eAll("\"","$");

    But it'll not work..
    Please give the solution.

    Thanks,
    Srinivas r.
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    The $ is a special character in the replacement string; you have to escape it
    for the regular expression compiler; because the \ is special to the java compiler
    you have to escape twice: "\\$".

    kind regards,

    Jos

    Comment

    Working...