I have the following value that needs to be assign into string -
ABC'DEFGH
How I can assign the sign of ' into string?
example -
str := 'ABC'DEFGH'
It's the same as with plain SQL: to escape a single quote, double it.
str := 'ABC''DEFGH';
You could also use the quoted string: q'<delimiter character><string<closing delimiter character>', e.g.:
str := q'{ABC'DEFGH}'
You can use a variety of characters as the quote delimiters. For more information, see the documentation for information on text literals, which includes how to use the q operator.
Related
I want to split a string by '|' delimiter and exclude those inside the brackets (). I used tokenize function to split by delimiter and have some issue with exclusion part(RegEx format). Please help.
Input: Test|Test1|Test2|(Test3|Test4)|Test5|(Test6)(Test7)|Test8
Output: Test,Test1,Test2,(Test3|Test4),Test5,(Test6)(Test7),Test8
Thanks in advance.
Perhaps the analyze-string function suffices to break up the string, I don't think the single example makes the rules clear but it would be like
analyze-string('Test|Test1|Test2|(Test3|Test4)|Test5|(Test6)(Test7)|Test8','(\([^)]*\))+')/*
/(if (. instance of element(fn:match)) then data() else tokenize(., '\|'))[normalize-space()]
either => string-join(',') that result or use
declare option output:method 'text';
declare option output:item-separator ',';
analyze-string('Test|Test1|Test2|(Test3|Test4)|Test5|(Test6)(Test7)|Test8','(\([^)]*\))+')/*
/(if (. instance of element(fn:match)) then data() else tokenize(., '\|'))[normalize-space()]
looking for elixir way to encode a uri component ie
javascript
encodeURI("&")
"&"
encodeURIComponent("&")
"%26"
Elixir
URI.encode("&")
"&"
pry(11)> URI.encode_query(%{k: " & "})
"+k=%26+"
basically I want encode_query but not have to do key value map and also encode spaces as %20, not +
found solution, uri.encode has default argument of
def char_unescaped?(char) when char in 0..0x10FFFF do
char_reserved?(char) or char_unreserved?(char)
end
for the second argument, by passing char_unreserved, the function will now encode reserved characters
URI.encode(" & ", &URI.char_unreserved?(&1))
"%20%26%20"
URI.encode/2 accepts second optional argument - a function to determine whether or not skip encode a char. So we can use the function that returns false (not skip) for any char:
URI.encode("&", fn(_) -> false end)
"%26"
How to get rest of the values from the variable
${random employee}= Convert To String ${random emp}
${replace}= Remove String Using Regexp ${random employee} ['\\[\\]\\,]
${splitline}= Fetch From Left ${replace} ${SPACE}
Output:
${replace} Alagu kartest1234+3alagu#gmail.cokartest1234+3ramu#gmail.com Developer Team B3 Team lead
${splitline} = Alagu
How to get rest of the values from the variable ${replace}
Keyword Split String from String standard library does this.
Split String string, separator=None, max_split=-1
Splits the string using separator as a delimiter string.
If a separator is not given, any whitespace string is a separator. In that case also possible consecutive whitespace as well as leading and trailing whitespace is ignored.
Split words are returned as a list. If the optional max_split is given, at most max_split splits are done, and the returned list will have maximum max_split + 1 elements.
Examples:
#{words} = Split String ${string}
#{words} = Split String ${string} ,${SPACE}
To get single values from #{words} use common array syntax: #{NAME}[i]. i is the index of the selected value. Indexes start from zero.
Just summertime curiosity about strings in R. Let use say that I have a x and y strings. As we know we have to quote single quotes in double quotes and vice versa.
x <- "a string with 'single' quotes"
y <- 'another one with "double" quotes'
paste0(x, y)
[1] "a string with 'single' quotesanother one with \"double\" quotes"
cat(x, y)
a string with 'single' quotes another one with "double" quotes
What if we have a string with single and double quotes too? I have tried this:
Backticks do not work (R triggers an error):
z <- `a string with 'single' quotes and with "double" quotes`
Use a \" instead of " and then use cat:
This works well but the problem is that users must add a backslash to every double quote.
z1 <- "a string with 'single' quotes and with \"double\" quotes"
what if we have a huge text file (like a .txt for example) with both type of quotes and we want to read in R?
At this point a (silly) solution to me seems to be: work outside R, do some manipulations (like substitute all " with \") and then read in R.
Is this a solution or does exist a better way inside R?
Here is just a little .txt file for example: Link, anyways for who is interested, the file is just a .txt with one line with this text:
a string with 'single' quotes and with \"double\" quotes
You may specify any alternate quoting characters as desired when reading text, e.g.
> p<-scan(what="character",quote="`")
1: `It is 'ambiguous' if "this is a new 'string' or "nested" in the 'first'", isn't it?`
2:
Read 1 item
> p
[1] "It is 'ambiguous' if \"this is a new 'string' or \"nested\" in the 'first'\", isn't it?"
Or, just read raw text, e.g. with readline as suggested by #rawr
> readline()
"It is 'ambiguous' if "this is a new 'string' or "nested" in the 'first'", isn't it?"
[1] "\"It is 'ambiguous' if \"this is a new 'string' or \"nested\" in the 'first'\", isn't it?\""
I'm new to regular expresions. I have a gigantic text. In the aplication, i need words of 4 characters and delete the rest. The text is in spanish. So far, I can select 4 char length words but i still need to delete the rest.
This is my regular expression
\s(\w{3,3}[a-zA-ZáéíóúäëïöüñÑ])\s
How can i get all words with 4 letters in asp.net vb?
/(?:\A|(?<=\P{L}))(\p{L}{4})(?:(?=\P{L})|\z)/g
Explanation:
Switch /g is for repeatedly search
\A is start of the string (not start of line)
\p{L} matches a single code point in the category letter
\P{L} matches a single code point not in the category letter
{n} specify a specific amount of repetition [n is number]
\z is end of string (not end of line)
| is logic OR operator
(?<=) is lookbehind
(?=) is lookahead
(?:) is non backreference grouping
() is backreference grouping
Using the character class provided above in another answer (\w does NOT match spanish word characters unfortunately).
You can use this for a match (it matches the reverse, basically matches everything that is NOT a 4-character word, so you can replace with " ", leaving only the 4-character words):
/(^|(?<=(?<=\W)[a-zA-ZáéíóúäëïöüñÑ]{4,4}(?=\W)))(.*?)((?=(?<=\W)[a-zA-ZáéíóúäëïöüñÑ]{4,4}(?=\W))|$)/gis
Approximated code in VB (not tested):
Dim input As String = "This is your text"
Dim pattern As String = "/(^|(?<=(?<=\W)[a-zA-ZáéíóúäëïöüñÑ]{4,4}(?=\W)))(.*?)((?=(?<=\W)[a-zA-ZáéíóúäëïöüñÑ]{4,4}(?=\W))|$)/gis"
Dim replacement As String = " "
Dim rgx As New Regex(pattern)
Dim result As String = rgx.Replace(input, replacement)
Console.WriteLine("Original String: {0}", input)
Console.WriteLine("Replacement String: {0}", result)
You can see the result of the regex in action here:
http://regexr.com?30n29
\[^a-zA-ZáéíóúäëïöüñÑ][a-zA-ZáéíóúäëïöüñÑ]{4}[^a-zA-ZáéíóúäëïöüñÑ]\g
Translated:
A non-letter, followed by 4 letters, followed by a non-letter. The 'g' indicated will match globally ... more than once.
Check out this link to find out more info on looping over your matches:
http://osherove.com/blog/2003/5/12/practical-parsing-using-groups-in-regular-expressions.html