I want to search for backslashes in the path and replace them with a forward slash, to give this: how to do reverse operation of the above like str=str.replace("\","//"); @srinivasgowda if you mean you want to replace forward slashes with backslashes, just swap the parameters: No for single backward slash() to double forward slash(//). Use a regex literal with the g modifier, and escape the forward slash with a backslash so it doesn't clash with the delimiters. This cookie is set by GDPR Cookie Consent plugin. (12/07-2016)", /t5/dreamweaver-discussions/php-replace-forward-slash-with-dash/m-p/8421066#M7375. As the How do I read / convert an InputStream into a String in Java? By clicking Accept All, you consent to the use of ALL the cookies. The escapeJava() method of the StringEscapeUtils class in the Commons LangS library can be used to insert JavaSW escape characters into a String. What are the "zebeedees" (in Pern series)? Yes, but this whole thing is a moot point. If there are UNC paths involved, they, I don't think these concerns are valid for the question as posed The space handling is a user interface issue; Unix systems, While this is true, I don't believe it's helpful for the OP's question which (AIUI) involved converting existing path names, which would already have included the backslashes in them. How to automatically classify a sentence or text based on its context? The JSON file and images are fetched from buysellads.com or buysellads.net. Where should I put