Javascript-PHP regular expression replacement

Source: Internet
Author: User
The regular expression in js is like this: {code ...} php is not written as follows: {code ...} my goal is to replace null in the string. how can I replace it? I tried it according to the answer below .. The reason is found because of json_encode (). how can this problem be solved...

The regular expression in js is as follows:

var str = "data\/ui_inner\/74\/";str.replace(/\\/,"");

Php is not written as follows:

$auto_url = preg_replace('/\\/','', $str);

My goal is to replace \ in the string with null. how can I replace it?

I tried it according to the answer below ..

The reason is found because of json_encode (). how can this problem be solved? Google me

Reply content:

The regular expression in js is as follows:

var str = "data\/ui_inner\/74\/";str.replace(/\\/,"");

Php is not written as follows:

$auto_url = preg_replace('/\\/','', $str);

My goal is to replace \ in the string with null. how can I replace it?

I tried it according to the answer below ..

The reason is found because of json_encode (). how can this problem be solved? Google me

We do not recommend that youjson_encodeBecausejson_encodePair/Escape output. for js, its content is still/Instead\/.

(PS: There are comments in the code below during the test.var_dump, Retain onlyecho)
Replaced:

Not replaced:

1.htmlThe code is as follows:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.