Questions tagged [rawstring]

A string literal which would be processed without any language-specific interpretation, avoiding the need of escaping characters and thus providing more legible strings.

Raw strings are particularly useful when a common character needs to be escaped, notably in regular expressions (nested as string literals), where backslash \ is widely used, and in DOS/Windows paths, where backslash is used as a path separator.

143 questions
9
votes
1 answer

In context of Python Raw string

My Python version is: ~$ python --version Python 2.6.6 I tried following in Python (I wants to show all): 1: \ use as escape sequence >>> str('Let\'s Python') "Let's Python" 2: \ use as escape sequence >>> 'Let\'s Python' …
Grijesh Chauhan
  • 57,103
  • 20
  • 141
  • 208
8
votes
4 answers

Raw string and regular expression in Python

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) #output: Today is 2012-11-27. PyCon starts…
fluency03
  • 2,637
  • 7
  • 32
  • 62
8
votes
2 answers

Python - Raw String Literals

I don't understand how raw string literals work. I know that when using r it ignores all specials, like when doing \n it treats it as \n and not as a new line. but then I tried to do this: x = r'\' and it said SyntaxError: EOL while scanning string…
ori
  • 369
  • 2
  • 6
  • 17
7
votes
4 answers

How to output """ in the "here docs" of scala?

In scala, "here docs" is begin and end in 3 " val str = """Hi,everyone""" But what if the string contains the """? How to output Hi,"""everyone?
Freewind
  • 193,756
  • 157
  • 432
  • 708
7
votes
3 answers

How to exclude C++ raw string literals from syntax highlighting in Vim?

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 raw string literals completely break the syntax…
maxschlepzig
  • 35,645
  • 14
  • 145
  • 182
6
votes
1 answer

Does R 4.0.0. make it possible to define foo"(...)" operators, similar to the newly introduced r"(...)" syntax?

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: unexpected string constant in "r"(asdasd)"" Does it mean that…
Karolis Koncevičius
  • 9,417
  • 9
  • 56
  • 89
6
votes
0 answers

Including a literal backtick in a String.raw template literal

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 template literal function so that I don't have to worry…
Mihai Parparita
  • 4,236
  • 1
  • 23
  • 30
6
votes
1 answer

Raw String Literals - Remove Leading Indentation

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 String Literals (which are a preview feature in Java…
Jacob G.
  • 28,856
  • 5
  • 62
  • 116
6
votes
2 answers

Are line breaks in raw strings platform-dependent?

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?
fredoverflow
  • 256,549
  • 94
  • 388
  • 662
6
votes
2 answers

When CPP line splicing is undone within C++0x raw strings, is a conforming implementation required to preserve the original newline sequence?

The latest draft of C++0x, n3126, says: Each instance of a backslash character (\) immediately followed by a new-line character is deleted, splicing physical source lines to form logical source lines. ... Within the r-char-sequence of a raw string…
Daniel Trebbien
  • 38,421
  • 18
  • 121
  • 193
5
votes
1 answer

How to make C++ raw string which includes raw string terminator?

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 <"(add)"> How can I modify this so it works?
freyone
  • 349
  • 1
  • 8
4
votes
3 answers

reading raw string from file in C#

I have the following raw-string literal : @"some text ""here"" and some more text" Everything works fine when I have this assigned to a string variable in a program. But when I put this string - "some text ""here"" and some more text" and read it,…
Aadith Ramia
  • 10,005
  • 19
  • 67
  • 86
4
votes
1 answer

What setting of clang-format (12.0.1) will not add a space between the R prefix and a raw string in C++?

What is the option for clang-format 12 (12.0.1) that puts a space between the R prefix and a raw string: std::string str = R"(raw string)"; vs std::string str = R "(raw string)"; The latter is not accepted by gcc (9.3.0) or the clang being used by…
rtillery
  • 367
  • 1
  • 10
4
votes
2 answers

'unraw' a string in JavaScript

How can I take a raw string in JavaScript and convert all the escape sequences to their respective characters? In other words, the reverse of String.raw. For example: unraw("\\x61\\x62\\x63 \\u{1F4A9} \\u0041"); // => "abc A"; I tried JSON.parse,…
Ian
  • 5,704
  • 6
  • 40
  • 72
4
votes
3 answers

swiftyjson cannot convert rawstring back to a json object

I have a json object like thies {"test" : "test"}, but if I convert it to a SwfiftyJSON.JSON object, and then I fetch the rawstring by function rawString(), then I convert the rawstring to a json object, but unfortunately, I can not get the correct…
YonF
  • 641
  • 5
  • 20
1 2
3
9 10