Avatar ·

What does the r#""# operator mean in Rust and how to use raw string literals?

Hello! I recently started learning Rust and came across an unclear construct in someone else's code. It was something like: ```rust let pattern = r#"^\\d+\\.\\d+\\.\\d+\\.\\d+$"#; let json = r#"{"name": "John", "age": 30}"#; ``` I see that there is a letter `r` before the string, and then the characters `#"` and `"#`. What does this even mean? I know that in Rust string literals are denoted by double quotes `"..."`, and the `\\` character is used for escaping. But here there is some magic with `#`. I am especially confused that inside this string there are regular double quotes. In a normal string I would have to write `\\"` for escaping, but here the quotes are as is. And also these hash symbols `#` on the edges — why are they needed? Can I do without them? I tried to write just `r"..."`, but the compiler gives an error.