Javascript + Replace forward slashes ‘/’ with backward slashes ‘\’.

Hi friends,

Using following Javascript sysntax you can replace forward slashes (‘/’) with backward slashes (‘\’) :

var strReplace = “C:\Temp\Temp1\Temp2\text.jpeg“;

strReplace = strReplace.replace(new RegExp(/\\/g),”/”);

Regardes,

Vijay

About these ads
This entry was posted in Uncategorized and tagged . Bookmark the permalink.

11 Responses to Javascript + Replace forward slashes ‘/’ with backward slashes ‘\’.

  1. blueprints says:

    Javascript String Replace Path

  2. Megharaja says:

    Thanks a lot for the valuable solutions.

  3. Hussain says:

    Nice Code, Thanks a lot

  4. Mario says:

    Hi, how would it be shifted, I mean, Replace backward slashes ‘\’ with forward slashes ‘/’.

  5. Trueman says:

    That is right, your description is wrong, you are replacing \ for /….
    what about the opposite one, how could it be done?

  6. Lou says:

    Use this to replace “/” with “\”. The code may not look right depending on your code editor, but it’ll work.

  7. Lou says:

    oops, forgot to add the code:
    strReplace = strReplace.replace(/\//g, “\\”);

  8. Lou says:

    Here is the code you guys are asking for:
    strReplace = strReplace.replace(/\//g, “\\”);

  9. Jens Haase says:

    Hi Lou,

    this doesn´t work with the built-in Javasript of Adobe Acrobat (V. 9.3). Do you have a solution for the Adobe crippled Javascript?

  10. Pingback: Punkchip | Removing forward slashes from a string

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s