What does "you better" mean in this context of conversation? In this article, we will see how to globally replace a forward slash in a JavaScript string. As the forward slash (/) is special character in regular expressions, it has to be escaped with a backward slash (\). 3 How to get value of string after last slash in JavaScript? Translate Jump to answer 1 Reply How to translate the names of the Proto-Indo-European gods and goddesses into Latin? First, find the last index of (/) using .lastIndexOf (str) method. This can be done using java.mysql support for forward slash in file path. Thanks, @Code_S: You also have to escape the backslash in the string, It works in the snippet because there are two backslashes and not only one like asked in the question, This does not work with only one backslash like asked in the question, Replace back slash (\) with forward slash (/) [duplicate], Path with backslashes to path with forward slashes javascript. This function will return a new string with the replaced string. This probably also works in Linux. Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features. We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. As the at java.lang.String.replaceAll (Unknown Source) at com.javacodeexamples.regex.RegExReplaceBackslash.main (RegExReplaceBackslash.java:9) So in short, if you are using the replace method, use \\ as the search string. The reason of this is because backslash is considered as an escape character for special characters (like \n for (Basically Dog-people). with index 4610 (2E16 or 568) literally (case sensitive) \/ matches the character / with index 4710 (2F16 or 578) literally (case sensitive) 2nd Alternative [a-zA-Z]+\/ Match a single character present in the list below [a-zA-Z] NtCreateFile also exposes an equivalent of openat(2), which isnt exposed via the Windows API. Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors. Your regex has been permanently saved and may be accessed with this link by anybody you give it to. You also have the option to opt-out of these cookies. Where should I put