Using quotation marks inside quotation marks
You could do this in one of three ways:
Use single and double quotes together:
print('"A word that needs quotation marks"')
"A word that needs quotation marks"Escape the double quotes within the string:
print("\"A word that needs quotation marks\"")
"A word that needs quotation marks"Use triple-quoted strings:
print(""" "A word that needs quotation marks" """)
"A word that needs quotation marks"
How to print double quotes inside ?
With a backslash before the double quote you want to insert in the String:
let sentence = "They said \"It's okay\", didn't they?"
Now sentence
is:
They said "It's okay", didn't they?
It's called "escaping" a character: you're using its literal value, it will not be interpreted.
With Swift 4 you can alternatively choose to use the """
delimiter for literal text where there's no need to escape:
let sentence = """
They said "It's okay", didn't they?
Yes, "okay" is what they said.
"""
This gives:
They said "It's okay", didn't they?
Yes, "okay" is what they said.
With Swift 5 you can use enhanced delimiters:
String literals can now be expressed using enhanced delimiters. A string literal with one or more number signs (#) before the opening quote treats backslashes and double-quote characters as literal unless they’re followed by the same number of number signs. Use enhanced delimiters to avoid cluttering string literals that contain many double-quote or backslash characters with extra escapes.
Your string now can be represented as:
let sentence = #"They said "It's okay", didn't they?"#
And if you want add variable to your string you should also add #
after backslash:
let sentence = #"My "homepage" is \#(url)"#
Using quotation marks inside a SQL string
You just need to double the double quotes inside your SQL (that's how you escape double quotes in VB.NET).
Assuming the initial statement from your post is your working SQL:
& " : " &
would become & "" : "" &
,
and DateAdd("d",-7,Now())
would become DateAdd(""d"",-7,Now())
.
The full statement:
Dim QuestionConnectionQuery As New OleDb.OleDbCommand("SELECT TOP 1 Questions.QuestionID, Questions.QuestionCategory & "" : "" & Questions.QuestionSubCategory AS Category FROM Questions WHERE (((Questions.QuestionDifficulty)=[?])) OR (((Questions.LastDateRevealed) Is Null)) OR ((Questions.LastDateRevealed)>=DateAdd(""d"",-7,Now())) ORDER BY Rnd(QuestionID);", QuestionConnection)
How can I print a quotation mark in C?
Try this:
#include <stdio.h>
int main()
{
printf("Printing quotation mark \" ");
}
VB.Net Using Quote Mark in Quote Marks
Here's one option:
"text" & Chr(34) & textbox1.text & Chr(34)
RegEx: Grabbing values between quotation marks
I've been using the following with great success:
(["'])(?:(?=(\\?))\2.)*?\1
It supports nested quotes as well.
For those who want a deeper explanation of how this works, here's an explanation from user ephemient:
([""'])
match a quote;((?=(\\?))\2.)
if backslash exists, gobble it, and whether or not that happens, match a character;*?
match many times (non-greedily, as to not eat the closing quote);\1
match the same quote that was use for opening.
Related Topics
Setting Y-Axis Limit in Matplotlib
Formatting Floats Without Trailing Zeros
Best Way to Replace Multiple Characters in a String
Getting Realtime Output Using Subprocess
Order of Keys in Dictionaries in Old Versions of Python
How to Catch and Print the Full Exception Traceback Without Halting/Exiting the Program
How to Locate Element Using Selenium Chrome Webdriver in Python Selenium
How to Rotate an Image Around an Off Center Pivot in Pygame
Print List Without Brackets in a Single Row
How to Remove a Key from a Python Dictionary
Plotting Time in Python with Matplotlib
How to Redirect Output with Subprocess in Python
How to Make Firefox Headless Programmatically in Selenium with Python