rawstring Questions
3
Are line breaks in raw strings platform-dependent?
val a = "one\ntwo";
val b = """one
two"""
println(a == b)
In other words, is the println statement above guaranteed to print true or not?
Wilhelminawilhelmine asked 21/10, 2017 at 9:4
14
Solved
Technically, any odd number of backslashes, as described in the documentation.
>>> r'\'
File "<stdin>", line 1
r'\'
^
SyntaxError: EOL while scanning string literal
>>> ...
5
Solved
I got a little confused about Python raw string. I know that if we use raw string, then it will treat '\' as a normal backslash (ex. r'\n' would be \ and n). However, I was wondering what if I want...
4
Solved
I came across this code snippet in C++17 draft n4713:
#define R "x"
const char* s = R"y"; // ill-formed raw string, not "x" "y"
What is a "raw string"? What does it do?
13
Solved
Is there any way to use raw strings in Java (without escape sequences)?
(I'm writing a fair amount of regex code and raw strings would make my code immensely more readable)
I understand that the ...
3
Solved
I don't understand the logic in the functioning of the scape operator \ in python regex together with r' of raw strings.
Some help is appreciated.
code:
import re
text=' esto .es 10 . er - 12 .23...
Telephony asked 10/6, 2019 at 9:15
7
Solved
What are the actual uses of String.raw Raw String Access introduced in ECMAScript 6?
// String.raw(callSite, ...substitutions)
function quux (strings, ...values) {
strings[0] === "foo\n"
string...
Monoculture asked 13/1, 2016 at 17:6
4
Solved
I have this code:
import os
path = os.getcwd()
final = path +'\xulrunner.exe ' + path + '\application.ini'
print(final)
I want output like:
C:\Users\me\xulrunner.exe C:\Users\me\application.ini
B...
7
Solved
From the python documentation on regex, regarding the '\' character:
The solution is to use Python’s raw string notation for regular
expression patterns; backslashes are not handled in any spec...
Selfassurance asked 13/10, 2012 at 7:42
1
Solved
R 4.0.0 brings in a new syntax for raw strings:
r"(raw string here can contain anything except the closing sequence)"
But this same construct in R 3.x.x produced a syntax error:
Error: unexpe...
Ludovick asked 24/4, 2020 at 11:43
10
Solved
Is there any way to have multi-line plain-text, constant literals in C++, à la Perl?
Maybe some parsing trick with #includeing a file?
I know you can do it with raw strings in C++11.
Mackenie asked 16/7, 2009 at 6:55
7
Solved
Consider:
>>> r"what"ever"
SyntaxError: invalid syntax
>>> r"what\"ever"
'what\\"ever'
So how do we get the quote, but not the slash?
And please don't suggest r'what"ever', be...
2
Solved
Let's say, we want to catch something with regex, using rawstring to define the pattern, which pattern has repeating elements, and variables inside. And we also want to use the format() string form...
Josiejosler asked 25/5, 2013 at 22:47
2
Solved
Consider a C++ file that has UNIX line endings (i.e. '\x0a' instead of "\x0d\x0a") and includes following raw string literal:
const char foo[] = R"(hello^M
)";
(where ^M is the actual byte 0x0d ...
1
Solved
I want to pass a raw string literals to [[deprecated(message)]] attribute as the message. The message is used again and again. So I want to avoid code repeat.
First, I tried to use static constexp...
Launder asked 27/8, 2019 at 3:53
0
I am working on a system that generates JavaScript, and I would like to minimize the amount of escaping that needs to be done for string literals. My current approach is to use the String.raw templ...
Welty asked 26/8, 2019 at 4:39
7
Solved
While asking this question, I realized I didn't know much about raw strings. For somebody claiming to be a Django trainer, this sucks.
I know what an encoding is, and I know what u'' alone does si...
Chemistry asked 17/1, 2010 at 16:22
2
Solved
In my JSON file, one of the fields has to carry the content of another file (a string).
The string has CRLFs, single/double quotes, tabs.
Is there a way to consider my whole string as a raw strin...
3
Solved
Quite honestly, raw string literals are a great addition to the C++ language. But (as expected) editors have a hard time to properly display those literals.
I am using Vim 7.4 and out-of-the-box r...
Coplanar asked 26/3, 2014 at 22:28
6
Solved
Is there a way to declare a string variable in Python such that everything inside of it is automatically escaped, or has its literal character value?
I'm not asking how to escape the quotes with sl...
2
Solved
This code works in Visual C++ 2013 but not in gcc/clang:
#if 0
R"foo(
#else
int dostuff () { return 23; }
// )foo";
#endif
dostuff();
Visual C++ removes the if 0 first. Clang expands the R raw s...
Veneration asked 23/6, 2015 at 8:2
1
Edit: Raw String Literals have been dropped from JDK 12, but I'm going to leave this question open and will edit it accordingly whenever Raw String Literals are reintroduced.
When testing Raw St...
Cary asked 18/11, 2018 at 2:51
2
I am opening a workbook in openpyxl thus:
wb = load_workbook(r'seven.xlsx', data_only=True)
The name of the spreadsheet won't always be know in advance, so I need to rewrite this hardcoding to ...
Stokowski asked 12/7, 2015 at 6:15
4
Solved
I'm confused about raw string in the following code:
import re
text2 = 'Today is 11/27/2012. PyCon starts 3/13/2013.'
text2_re = re.sub(r'(\d+)/(\d+)/(\d+)', r'\3-\1-\2', text2)
print (text2_re) #...
1
I use R"(...)" to define a raw string but, if the string actually contains a raw string terminator )", the compiler will complain.
For example:
auto tag = R"("(add)")"; // try to get string <...
1 Next >
© 2022 - 2024 — McMap. All rights reserved.