Questions tagged [backslash]
The backslash character \ (not to be confused with slash /) is used in many languages to quote the next character, i.e. to make it lose its special meaning. It is also the directory separator in file paths under DOS and Windows.
939
questions
-2
votes
0
answers
59
views
remove backslash from json string c#
i try to send api call, But I get an error
this is my code
static async Task Main()
{
string query = @"query MyQuery {ethereum(network: bsc) {transfers(currency: {is: ""...
0
votes
2
answers
38
views
Extract numbers from string with backslash
I need to extract the numbers from a string in the following format: '183\118\40'. I tried:
st = '183\118\40'
re.findall(r"[-+]?(?:\d*\.\d+|\d+)", st)
output: ['183', '8']
st.split('\\')
...
-1
votes
0
answers
31
views
Java JSONArray replaces apostrophes to backslashes when adding strings
In my project I convert list of maps to jsonArray. However, sometimes there are values which are maps, So I convert them to Strings then add them to the JSONArray. But when I do this, the apostrophes ...
0
votes
0
answers
16
views
Make sure copy pasting directory paths is possible in R: solve the backward slash problem [duplicate]
Does not work
my_str_input2 = "C:\\Users\\van R\\OneDrive - GCloud Belgium\\DATA\\SHARED\PROJECTS\database_vergelijking\AS400\geupdate_lijst_Jan"
input_path4 = "C:\Users\van R\OneDrive ...
-2
votes
3
answers
62
views
Search and replace backslash except one thing
I want to replace \ with \\ except \N.
So I got so far
sed ‘s/\\/\\\\/g’
But I’m not sure how to add ignore
Sample:
aa \N aa
\N aa aa
aa aa \N
\N \N aa
\N aa \N
aa \N \N
\N \N \N
aa aa ...
1
vote
1
answer
48
views
Can you use "\" in a dictionary inside Python?
I'm creating a variation of the vigenere cipher using all the ASCII characters using a dictionary. The first few lines are okay, but then I get an error for the value 3.
vigenereDictionary = { "@&...
0
votes
2
answers
38
views
POST /api/v2/statements to Snowflake with Insert statement removes my \\ (double backslashes)
I try to POST /api/v2/statements to Snowflake with statement
INSERT INTO test (EXPRESSION) VALUES ('(?<=\\?)|&')
In database I have (?<=?)|&.
But I need (?<=\?)|&. That is why I ...
2
votes
1
answer
67
views
How to list contents of a specific directory in powershell?
I'm rather baffled by Powershell in general. Very weird. Anyway, I've read:
Powershell's equivalent to Linux's: ls -al
so I now know how to list the contents of the current directory. But how ...
-2
votes
1
answer
138
views
How to replace single backslash with double backslashes in paths using Delphi?
Here are my codes:
var
Form1: TForm1;
///--- Değişkenler ---///
//-- String --//
str_ÖgeninKonumu: String;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
...
3
votes
3
answers
118
views
How do you match \'
I need a regex to match \' <---- literally backslash apostrophe.
my $line = '\'this';
$line =~ s/(\o{134})(\o{047})/\\\\'/g;
$line =~ s/\\'/\\\\'/g;
$line =~ s/[\\][']/\\\\'/g;
printf('%s',$line);
...
0
votes
2
answers
214
views
Can I return a single backslash in a JSON response in FastAPI? [duplicate]
Seems like a really simple question and it's not clear what the correct answer is here.
We understand that backslashes are a special delimiter in JSON.
From our database we're being returned a field ...
-4
votes
1
answer
102
views
How can I remove \ (backslash)? [duplicate]
I use gin web framework and this is data in redis
[
{
"Score": 12,
"Member": "{"empname":"DDDDDDDD","empid":20}"
},
{
&...
0
votes
1
answer
39
views
Making a re.sub using a list of punctuation
Is there a way to take a list of punctuation, and put it into a re.sub. I was using f-string literals but the escape character breaks everything. Should I just type it manually?
marks = [',', '。', '—',...
0
votes
0
answers
46
views
Laravel/Eloquent returns JSON with slashes
This is my database
I want to return content of "content" column with my API. In my controller I have
public function index()
{
return Quiz::pluck('content');
}
And ...
0
votes
2
answers
160
views
How to avoid double backslashes in string literals being replaced with single backslash? [duplicate]
Python string replaces double backslash with a single backslash? How avoid replace? I need to keep \\n as it is.
Code:
if __name__ == "__main__":
str1 = '{"en":"M L\\n\\...
0
votes
2
answers
80
views
Python: single backslash automatically replaced by double backslash when printing a list [duplicate]
I have an array/list of strings that contain a single backslash.
stringArray = ['this \\ is', 'a \\ sample', 'backslash \\ text']
When I print them in the console separately they are displayed ...
-1
votes
1
answer
37
views
How to type in the file directory with backslashes? [duplicate]
I'm trying to draw an image using Graphics2D in Java, but the path cannot be read because Illegal escape character in string literal
I am using this line of code:
g2.drawImage("C:\Users\User\...
0
votes
0
answers
12
views
When there are only backslash in C/C++output
Is that legal to write : printf("%s","") ?
or it must be : printf("%s","\") ?
0
votes
0
answers
130
views
Path separator backslash in zip files, created from dll, .Net 4.8
I'm developing a dll in C# that should create a zip-archive.
According to project settings in VS I use .Net Framework 4.8. So I assumed that this fix should be already applied and path separator ...
0
votes
1
answer
44
views
Couldn't replace symbol with '\w' [duplicate]
I've need to create regular expression using existing pattern. In my task user enters filename and pattern, my function should return True in case they are compatible and False if not.
For example, if ...
0
votes
1
answer
50
views
How to check if a string has '\' in python?
I know that I can print '\' like this:
print('\\')
But the same logic doesn't work when I try to check if '\' is in a string, like this:
if '\\' in 'blaablaa\something'
So how can I do that?
0
votes
2
answers
263
views
Fetching cloudwatch log by aws cli but it gives json output with backslash. But I want JSON output without backslash
I am using AWS cli to fetch cloudwatch log but after fetching the JSON output includes backslash with key and value. But I am checking this log from console then that is absolutely fine( there are ...
1
vote
1
answer
45
views
how to backslash a backslash in zsh bindkey?
I would like to replace the key as this:
bindkey -s ',;' "| grep -A5 \"^\\s{3,}-\"\ei"
in my zshrc, but the \\s part (which should be \s for space in PCRE), gives something like ...
1
vote
1
answer
54
views
Avoid backslashing of space character in GNU parallel input
eNeed you help over here!
What I want
Pass a space-containing argument to a command using GNU parallel so it doesn't backslash it.
Example:
parallel --dry-run COMMAND {} ::: opt1 "opt2 arg" ...
0
votes
0
answers
40
views
Force odd number of backslashes in dictionary
I am specifically looking to print this in the terminal {'Name': '[{\\\"test\\\\":\\\"somedata\\\"}]'}
So far I can get 2 slashes or 4 slashes but I am not sure how to three ...
0
votes
1
answer
103
views
how do I create a string using a backslash and a variable in python?
I'm trying to execute this command on a Windows machine:
dir \\hostname\sapmnt\SID\SYS\profile\SID_*04_hostname /b /a-d
So far, I have this code:
cmd_drive = r"\\"
local_hostname = "...
0
votes
0
answers
122
views
C++: How to replace single backslash with double backslash within pathnames?
I read pathnames from an input-file using strtok().
Then, within my program, I will get a char[] containing these pathnames, for example:
"C:\docs\technical-manuals\printer\Brother_4155_manual....
0
votes
1
answer
313
views
How do I write a single backslash (\) in a string?
I am trying to detect non printable characters in a string ('\n', '\r', etc.) and insert a single backslash before them. So, for example if I have a string "Hello\nWorld", I want it to be &...
0
votes
0
answers
31
views
Nodejs - support backslash in json
I want to keep backslash when I am doing JSON.parse().
I have created a proxy service to hit a third-party service on my microservice application.
API -> POST <base_url>/api/v1/action
{
&...
-1
votes
2
answers
238
views
Saving files directory with "forward slash" in a txt file with cmd
as the subject suggest, i need to save some directories of some files from a folder to a txt file getting "forward slash".
So, i made this .bat with this simple string:
dir *.* /a/b/s > F:...
-2
votes
3
answers
258
views
Using backslash (\) inside a String variable in java [duplicate]
I am not able to get the message value in the desired format.
String url = "sample"
String message ="/test{\"url\":"' + url + '\"}
The desired value of message is &...
0
votes
2
answers
89
views
Use preg_replace() to add two backslashes before each match
I have code below, what I need to change to get result mercedes\\-benz instead of mercedes\-benz
$value = 'mercedes-benz';
$pattern = '/(\+|-|\/|&&|\|\||!|\(|\)|\{|}|\[|]|\^|"|~|\*|\?|:|\\...
0
votes
2
answers
110
views
How to add single backslash to a Python list? [duplicate]
I want to add single backslash element to my list. I used print("\\") and it printed single backslash; however, when I try to add "\\" to my list, it adds double backslash. How can ...
1
vote
1
answer
111
views
Remove all values in a string before a backslash
I have this string
AttendanceList
XXXXXX
US\abraham
EU\sarah
US\gerber
when i try to use -replace it replaces all characters inserted in square bracket (including the first line AttendanceList)
$...
0
votes
0
answers
624
views
Decode json string to struct from response data in Swift
I have a test server written in python which produces json output on single path: '/'
import json
from fastapi import FastAPI
from uvicorn import run
app = FastAPI()
@app.get('/')
def main():
...
2
votes
1
answer
145
views
In C, is the backslash character (\) required when one needs to split arguments of functions or logical conditions into multiple lines?
I recently saw this snippet of code:
static HAL_StatusTypeDef Program_Flash_Page(uint32_t const page_address, \
void* const pBufferData, uint32_t const nBufferSize) {
uint32_t Address = ...
2
votes
1
answer
94
views
Why is raw string literal parsed before trailing backslash?
From Phases of translation, backslash joining next line happens in Phase 2 and string literal evaluation happens in Phase 3. Then why does the following code does string evaluation before?
#include<...
0
votes
1
answer
51
views
How to replace backslashes to a different character in a string Python
I want to know how to use Python's str.replace() function (or similar) to replace Backslashes...
When i try to do it:
>>> temp = r"abc\abc"
>>> temp.replace(r'\'', '...
-1
votes
1
answer
538
views
Gson Json conversion adding extra back slash
I am working on a service that has the following code (I can change this code):
import com.google.gson.JsonObject;
import com.google.gson.Gson;
Gson gson = new Gson();
JsonObject json = new ...
1
vote
0
answers
18
views
pgAdmin 4 psql Tool won't let me backslash [closed]
I did'nt find any answer for this online.
I've installed pgadmin4 on mac and when I'm in the psql tool (wich is like the terminal), I want to type db=# \dt to see my db tables.
Unfortunately, it won't ...
0
votes
2
answers
185
views
System.get_env in elixir and new line (\n)
~ ❯ export TEST_KEY='hello\nworld' && iex
iex(1)> System.get_env("TEST_KEY")
"hello\\nworld"
When running System.get_env/1 on a string with \n it inserts an extra ...
2
votes
1
answer
161
views
How to print a literal backslash to get \pm in a pandas data frame to generate a proper error bars in a latex table in python?
I have obviously seen How to print a single backslash? and related duplicates can't print '\' (single backslash) in Python, How to print a single backslash in python in a string?, Quoting ...
0
votes
2
answers
95
views
Why Python replaces double backslashes with one and how can I keep it double
I am new to Python and I have difficulties with the above-mentioned problem.
I have a loop here that gives me paths of all folders that I need
for i in folder_names:
print(str("pd....
0
votes
2
answers
72
views
Extracting 8 characters after the last backslash in a string using R
I have a vector that includes the following types of data in R(more than just the two here):
df <- c("04 IRB/IEC and other Approvals\04.01 IRB/IEC Trial Approvals\04.01.02 IRB/IEC Approval&...
0
votes
2
answers
179
views
Is there a way to use newline characters in vue.js
I would like to use a newline character (\n) in a string in vue.js
For example:
created() {
this.buttons = [
{
id: 1,
text: "Button \n 1",
},
{
...
1
vote
1
answer
264
views
Pandas eval with backslash in column names
I have a dataframe like this
df=pd.DataFrame([1,2,3],columns=['a\\b'])
a\b
0 1
1 2
2 3
and I want to evaluate as expression like 'a\b<2' on this dataframe.
df.eval('a\\b<2')
When I ...
-1
votes
4
answers
725
views
how to escape file path in bash script variable
I would like to escape a file path that is stored in a variable in a bash script.
I read several threads about escaping back ticks or but it seems not working as it should:
I have this variable:
The ...
1
vote
2
answers
130
views
Replace all the backslash '\' with frontslash '/' during Data Cleansing activity in Python before importing the data in MySQL
I have a DataFrame of type: pandas.core.frame.DataFrame, imported from CSV file which has a column with links having elements as shown below
sno
link
A
C:\Users\Documents\SQL\Python Codes\
B
D:/...
-2
votes
1
answer
184
views
How to replace backslashes?
Due to a single backslash I am not able to send the exact value to the server, so single backslashes need to be replaced with double backslashes in the script.
I use replace function as shown below ...