backslash

why 3 backslash equal 4 backslash in php?

。_饼干妹妹 提交于 2019-12-01 08:42:24
<?php $a='/\\\/'; $b='/\\\\/'; var_dump($a);//string '/\\/' (length=4) var_dump($b);//string '/\\/' (length=4) var_dump($a===$b);//boolean true ?> Why is the string with 3 backslashes equal to the string with 4 backslashes in PHP? And can we use the 3-backslash version in regular expression? The PHP reference says we must use 4 backslashes. Note: Single and double quoted PHP strings have special meaning of backslash. Thus if \ has to be matched with a regular expression \\ , then "\\\\" or '\\\\' must be used in PHP code. $b='/\\\\/'; php parses the string literal (more or less) character by

why 3 backslash equal 4 backslash in php?

让人想犯罪 __ 提交于 2019-12-01 06:25:31
问题 <?php $a='/\\\/'; $b='/\\\\/'; var_dump($a);//string '/\\/' (length=4) var_dump($b);//string '/\\/' (length=4) var_dump($a===$b);//boolean true ?> Why is the string with 3 backslashes equal to the string with 4 backslashes in PHP? And can we use the 3-backslash version in regular expression? The PHP reference says we must use 4 backslashes. Note: Single and double quoted PHP strings have special meaning of backslash. Thus if \ has to be matched with a regular expression \\ , then "\\\\" or '\

Explain Backslash in C

◇◆丶佛笑我妖孽 提交于 2019-12-01 05:49:52
Can anyone please explain the below code and please also explain the role of backslash( \ ) in such situations. And what \' , \" , \ooo , \ \ , \? means? #include <stdio.h> int main(){ char a = '\010'; char y = '010'; printf("%d,%d",a,y); return 0; } output: 8,48 This '\010' is a octal escape sequence 10 in octal is 8 in decimal and it will be promoted to an int when calling printf so that explains that value. This '010' is a multi-character constant and it's value is implementation defined, if we look at the C99 draft standard section 6.4.4.4 Character constants paragraph 10 says( emphasis

Regex to replace single backslashes, excluding those followed by certain chars

天大地大妈咪最大 提交于 2019-12-01 04:58:22
I have a regex expression which removes any backslashes from a string if not followed by one of these characters: \ / or }. It should turn this string: foo\bar\\batz\/hi Into this: foobar\\batz\/hi But the problem is that it is dealing with each backslash as it goes along. So it follows the rule in that it removes that first backslash, and ignores the 2nd one because it is followed by another backslash. But when it gets to the 3rd one, it removes it, because it isn't followed by another. My current code looks like this: str.replace(/\\(?!\\|\/|\})/g,"") But the resulting string looks like this

Replace double backslashes with a single backslash in javascript

寵の児 提交于 2019-12-01 04:12:26
I have the following problem: I have a script that executes an AJAX request to a server, the server returns C:\backup\ in the preview. However, the response is "C:\\backup\\" . Not really a big deal, since I just thought to replace the double slashes with single ones. I've been looking around here on stack, but I could only find how to replace single backslashes with double ones, but I need it the other way around. Can someone help me on this matter? This should do it: "C:\\backup\\".replace(/\\\\/g, '\\') In the regular expression, a single \ must be escaped to \\ , and in the replacement \

Explain Backslash in C

↘锁芯ラ 提交于 2019-12-01 03:50:14
问题 Can anyone please explain the below code and please also explain the role of backslash( \ ) in such situations. And what \' , \" , \ooo , \ \ , \? means? #include <stdio.h> int main(){ char a = '\010'; char y = '010'; printf("%d,%d",a,y); return 0; } output: 8,48 回答1: This '\010' is a octal escape sequence 10 in octal is 8 in decimal and it will be promoted to an int when calling printf so that explains that value. This '010' is a multi-character constant and it's value is implementation

Different behaviours of treating \\ (backslash) in the url by FireFox and Chrome

∥☆過路亽.° 提交于 2019-12-01 03:12:57
BACKGROUND According to my experience when my ubuntu workstation is configured on domain with active directory, the user name created for me was according to the following pattern. domain_name\user_name Using the userdir extensions of apache on linux will require to use user name in the URL in order to access public_html in the home directory. http://localhost/~domain_name\user_name PROBLEM A: Chrome converts all the backslash ' \ ' characters in the URL to forward slash ' / ' and the resultant url becomes as under that is totally different and always results Not Found . http://localhost/

Path with backslashes to path with forward slashes javascript

只愿长相守 提交于 2019-12-01 03:10:51
I'm trying to make a local xml file parsing "application" for some colleagues and i'm using the current function to retrieve the files: function ShowFolderFileList(folderspec) { var fso, f, f1, fc, s; fso = new ActiveXObject("Scripting.FileSystemObject"); f = fso.GetFolder(folderspec); fc = new Enumerator(f.files); s = ""; for (; !fc.atEnd(); fc.moveNext()) { var pathString = fc.item(); $("#test").append(pathString + "<br />"); } } The problem with this function it returns a string similar to: C:\Users\SomeUser\Desktop\cool\Archief\CDATA1.xml I need to replace the backward slashes to forward

Regex to replace single backslashes, excluding those followed by certain chars

假如想象 提交于 2019-12-01 02:43:43
问题 I have a regex expression which removes any backslashes from a string if not followed by one of these characters: \ / or }. It should turn this string: foo\bar\\batz\/hi Into this: foobar\\batz\/hi But the problem is that it is dealing with each backslash as it goes along. So it follows the rule in that it removes that first backslash, and ignores the 2nd one because it is followed by another backslash. But when it gets to the 3rd one, it removes it, because it isn't followed by another. My

Replace double backslashes with a single backslash in javascript

我与影子孤独终老i 提交于 2019-12-01 01:19:08
问题 I have the following problem: I have a script that executes an AJAX request to a server, the server returns C:\backup\ in the preview. However, the response is "C:\\backup\\" . Not really a big deal, since I just thought to replace the double slashes with single ones. I've been looking around here on stack, but I could only find how to replace single backslashes with double ones, but I need it the other way around. Can someone help me on this matter? 回答1: This should do it: "C:\\backup\\"