I am trying to search customers by name but some customer names contain single quote e.g. Saul's and this throws an error. How can I escape the single quote to resolve the error and search for the customer record?
Best Answer
A
Amanda Wong
said
almost 6 years ago
Hi Saul, you can use gsub to help you escape single quotes. Any of these should work:
"Saul's".gsub("'", {"'"=>"\\'"})
"Saul's".gsub("'","\\\\'")
Answer
Amanda Wong
said
almost 6 years ago
Hi Saul, you can use gsub to help you escape single quotes. Any of these should work:
Saul Macht
Escape single quote
I am trying to search customers by name but some customer names contain single quote e.g. Saul's and this throws an error. How can I escape the single quote to resolve the error and search for the customer record?
Hi Saul, you can use gsub to help you escape single quotes. Any of these should work:
Amanda Wong
Hi Saul, you can use gsub to help you escape single quotes. Any of these should work: