Questions tagged [backslash]

The backslash character \ (not to be confused with slash /) is used in many languages as an escape character to modify the meaning of the following character. It is also the directory separator in file paths under DOS and Windows.

The backslash character \ is a mirror version of the slash character /, created for use in computing. Its meaning depends on the context.

  • In many languages, \ followed by a character that has a special meaning makes the next character lose its special meaning. This is especially true inside string literals and regular expressions : for example, in many languages, "a\\b\"" represents the 4-character string a\b".
  • Sometimes \ gives the next character a special meaning. This is mostly the case when \ is followed by a letter or digit in a string literal, where it can be used to specify a control character or other special character. For example, \n specifies a newline in many languages, and \123 often specifies the character whose octal value is 123 (but note that some languages have different rules).
  • In DOS and Windows , the \ character is the directory (folder) separator in file paths. For example, c:\windows\cmd.exe is the file called cmd.exe in the directory called windows at the root of the c: drive.
  • In (La)TeX , \ starts a command name.
  • In Haskell , \ introduces a lambda expression .
991 questions
-2
votes
1 answer

Substituting backlashes with forward slashes in a string

Edited question: I am writing a python function that takes the string of a path as copy-pasted from windows (so with backslashes) and returns a string with forwardslashes, that can be used by python as a path. The problem arises with the combination…
Pauli
  • 170
  • 3
  • 9
-2
votes
1 answer

I don't understand why backslash is used in extends class in php code

class SwiftMailerTestCase extends \PHPUnit_Framework_TestCase why coder uses backslash in extends class in above php code
zahid
  • 23
  • 2
-2
votes
3 answers

How to remove single backslashe from string in php

I am trying to remove single backslash from string $str = "Lionel Messi\'s is a footballer of the year."; $str = stripslashes($str); But it is not working.
Kooldandy
  • 545
  • 4
  • 15
-2
votes
1 answer

Replacing double backslash ("\\") with a single backslash ("\")

My program retrieves a value a registry key(a path to GTA's folder). I'm using the following code to retrieve it: private static string PathName { get { using (RegistryKey registryKey =…
Nutz
  • 79
  • 2
  • 11
-2
votes
2 answers

Absence of backslash in the hardcoded variable output , but present in file output

#include #include #include using namespace std; int main () { string strFile = ""; ifstream myfile ("data.doc"); string strPgm = "{ \"c\" : { \"p1\": \"v1\", \"p2\":\"v2\" } }"; cout << "\n string from program is : "…
BusyTraveller
  • 183
  • 3
  • 14
-2
votes
2 answers

writing to shared memory core dump segmentation fault

I need to write to shared memory, thus I have #define FLAGS IPC_CREAT | 0644 int main() { key = ftok("ex31.c", 'k'); shmid = shmget(key, 3, FLAGS); shmaddr = shmat(shmid,0,0); // THOSE LINES WORK AS EXPECTED char* userInput = malloc(5); read(0,…
Zohar Argov
  • 143
  • 1
  • 1
  • 11
-2
votes
3 answers

Remove Backslash and Quotations in R

How do I remove the quotes from the following string in R? test = "\"LAST4\"" noquote(test) [1] "LAST4" I'm reading in the data manually and I can't remove the quotations and backslashes.
user13317
  • 451
  • 3
  • 13
-2
votes
1 answer

Backslash using for escaping qute regenerate after asigning String

in ToString methode of my Entity, i try to generate a informational string includes quotes. so i use backslash before quote and everything is good until i try to assign return value to a string variable and after that all backslash comeback .here…
Mahdi
  • 748
  • 14
  • 24
-2
votes
1 answer

removing double backslash from string containing some of them

I'm having trouble cause I can't define a function to do this: Input: "(case (+ 5 5) ((4 9 1) 'd64)\\n((1 2) 'pepito)\\n((10) 'jorgito)" Output: "(case (+ 5 5) ((4 9 1) 'd64)\n((1 2) 'pepito)\n((10) 'jorgito)" I've tried this and many other, without…
freinn
  • 1,049
  • 5
  • 14
  • 23
-2
votes
2 answers

Escape quote in Python

I'm trying to run the command: '"Isn\'t," she said.' The output is: "Isn\'t," she said. Why the output is not: "Isn't," she said. Anyone knows what's the rule for this? Thanks
Roger
  • 23
  • 2
-2
votes
4 answers

Backslash characters in PHP

I don't understand the function of the two backslashes on the following line... echo "

Hello, world!

"; of this code:
Preston blah
  • 229
  • 1
  • 3
  • 7
-3
votes
0 answers

Blackslash is converted to double backslashes in python. Im trying to open a file in the code and windows uses backslashes to get to different folders

I'm using this command in my code with open(r"files\data.txt", "r") as file: and I'm getting this error No such file or directory: 'files\\data.txt' I've also tried using \ as I've seen this mentioned as a solution but it still doesn't work with…
Risly
  • 1
-3
votes
3 answers

Remove all files from Git repo history with path having escape \ in filename with git filter-repo

I have special filenames with escape \ characters stored in Git repository on Debian 10 Linux. Problem: it is not possible to git checkout files on Windows, which have incompatible characters in the filename. Example: git log --all --name-only -m…
klor
  • 1,237
  • 4
  • 12
  • 37
-3
votes
1 answer

How to use backslash on Python?

I’m trying to write code. I’m very new to Python, and i’m using an interpreter on Visual Studio Code. I’m trying to write multiple lines of code, but the \ isn’t working, or i’m doing it wrong. Example: print(‘hi’) \ print(‘hello’) \ I would expect…
teddy
  • 1
-3
votes
1 answer

How to stop Golang from replacing double-quotes with backslashes when executing a Windows command?

I am writing a program in Golang that will use Mozilla's Thunderbird email client to send email. The Windows command that should be executed is: start "" "C:\Program Files (x86)\Mozilla Thunderbird\thunderbird.exe" -compose…
Sean H. Worthington
  • 1,701
  • 15
  • 9
1 2 3
65
66