Like with an apostrophe in the seach - oracle

How do I search for "Land's End" in a LIKE syntax?
OR UPPER(MOPACTIVITY.MOPDESCRIPTION) LIKE '%LANDS'END%'
The apostrophe is making the code fail, but it is part of the company name. How do I make this work?

double it! or use special quoting http://www.oracle-developer.net/display.php?id=311

Related

Escape double quotes in qsTrId source string

For a project I'm working on, I'm forced to use qsTrid() that need the following syntax to work:
//% "My string"
text: qsTrId('my_string')
Until you need to use double quotes there are no drawbacks in using this for simple strings, still you cannot use arguments normally like you would do for qsTr().
The problem arise when you need something like this:
//% "My "super" string"
text: qsTrId('my_super_string')
lupdate will only see "My " as source string, since the double quotes are used as delimiter.
Up to now the best I could achieve is this:
//% "My ""super"" string"
That will produce "My super string", the string is not broken but is missing the double quotes.
I've tried searching online and in the documentation if there are special rules in this case, but had no luck.
I tried using single quotes but lupdate does not see the string at all in this case.
I cannot use \" because the source string is used in the other language that will not be translated, but if it is the only solution I'll try to propose it.
Anyone know how to correctly escape the double quotes in this situation?

Escape single quote in Xtend template expression

I have a very simple question, but could not figure it out by Google search, please help.
I want to produce this string '\u0000' (note the simple quote marks surrounding it!) using the following simple Xtend method containing a template expression:
def String makeDefaultChar()
{
''''\u0000''''
}
However, this is not accepted as proper syntax (probably because of the four ''''. Is there an escape character for this use case or what is the right syntax?
Thank you in advance!
P.S.
Of course I could use plain Java string like this "'\\u0000'" to achieve the same, but I want to use an Xtend template expression.
My Xtend version is: 2.9.1.v201512180746
There is no "escaping" in template expressions, so you have to use the workaround you mentioned:
'''«"'\\u0000'"»'''
or
'''«"'"»\u0000«"'"»'''
Related discussion: https://groups.google.com/forum/#!topic/xtend-lang/bVZ0nKmQGAI
Single quotes are allowed within Xtend templates as long as they do not occur at the beginning or the end of the template. So a simple workaround is to add an empty expression before/after the single quote:
'''«»'\u0000'«»'''

How to check for link regex in text with RSpec?

I have a string of html that looks like this:
Click the link below:
Verify
I would like to check for the presence of the link, but substitute wildcards for the params that I don't care about. I've tried this but it doesn't match:
expect(html).to match %r{Verify}
How can I get this to work?
You need to escape special characters that could be interpreted as regex matchers. Here the ?
expect(html).to match %r{Verify}

Escaping an apostrophe in golang

How can I escape an apostrophe in golang?
I have a string
s = "I've this book"
and I want to make it
s = "I\'ve this book"
How to achieve this?
Thanks in advance.
Escaping a character is only necessary if it can be interpreted in two or more ways. The apostrophe in your string can only be interpreted as an apostrophe, escaping is therefore not necessary as such. This is probably why you see the error message unknown escape sequence: '.
If you need to escape the apostrophe because it is inserted into a database, first consider using library functions for escaping or inserting data directly. Correct escaping has been the culprit of many security problems in the last decades. You will almost certainly do it wrong.
Having said that, you have to escape \ to do what you want (click to play):
fmt.Println("\\'") # outputs \'
As you're using cassandra, you can use packages like gocql which provide you with parametrized queries:
session.Query(`INSERT INTO sometable (text) VALUES (?)`, "'escaping'").Exec();

Ruby Regular Expressions: Matching if substring doesn't exist

I'm having an issue trying to capture a group on a string:
"type=gist\nYou need to gist this though\nbecause its awesome\nright now\n</code></p>\n\n<script src=\"https://gist.github.com/3931634.js\"> </script>\n\n\n<p><code>Not code</code></p>\n"
My regex currently looks like this:
/<code>([\s\S]*)<\/code>/
My goal is to get everything in between the code brackets. Unfortunately, it's matching up to the 2nd closing code bracket Is there a way to match everything inside the code brackets up until the first occurrence of ending code bracket?
All repetition quantifiers in regular expressions are greedy by default (matching as many characters as possible). Make the * ungreedy, like this:
/<code>([\s\S]*?)<\/code>/
But please consider using a DOM parser instead. Regex is just not the right tool to parse HTML.
And I just learned that for going through multiple parts, the
String.scan( /<code>(.*?)<\/code>/ ){
puts $1
}
is a very nice way of going through all occurences of code - but yes, getting a proper parser is better...

Resources