I need to write symbol & to variable in CMD for word is like = adc&def.
There are two ways to do that:
Use a caret ^ to escape the character. It will work for these characters: & < > ^ | (You escape a caret by using a caret).
Use double-quotes. By using double quotes it's not necessary to escape characters (except exclamation marks when using EnableDelayedExpansion.
So, the final solution could be:
set "var=abc&def"
or set var=abc^&def.
Related
I m new to snowflake.
Input String : ["http://info.wealthenhancement.com/ppc-rt-retirement-planning"]
Output String : info.wealthenhancement.com/ppc-rt-retirement-planning
Please help to get output string.
Thanks
Use the substr function to only take characters from the 8th character to the end:
select
'http://info.wealthenhancement.com/ppc-rt-retirement-planning' as orig_value,
substr(orig_value, 8) as new_value
The output is:
+-------------------------------------------------------------+-------------------------------------------------------+
|ORIG_VALUE | NEW_VALUE |
+-------------------------------------------------------------+-------------------------------------------------------+
|http://info.wealthenhancement.com/ppc-rt-retirement-planning | info.wealthenhancement.com/ppc-rt-retirement-planning |
+-------------------------------------------------------------+-------------------------------------------------------+
This will work for http and https URLs by splitting using // as a delimiter. Only the last statement is required. The other two show how it's done built into steps:
-- Set a session variable to the string
set INPUT_STRING = '["http://info.wealthenhancement.com/ppc-rt-retirement-planning"]';
-- Trim leading and trailing square brackets and double quotes
select (trim($INPUT_STRING, '"[]'));
-- Split using // as a delimiter and keep only the right part and cast as string
select split((trim($INPUT_STRING, '"[]')), '//')[1]::string as URL
Im trying to create a string recognition rule to run in flex,the string can consist of escape characters(\n , \t , \r , \ , " , '), symbols( -, +, *, /, :, _, $, !, #, #, &, ~, ^, (, ) ) and a-zA-Z0-9 characters,i have tried many variations of the code below,but i keep getting the same error mentioned above.
ESCAPECHAR [\n] | [\t] | [\r] | [\] | ['] | ["]
SYMBOLS [-+*/:_$!##&~^()]
CHARACTERS [0-9a-zA-Z]
STRING ("({ESCAPECHAR} | {SYMBOLS} | {CHARACTERS})*") | ('({ESCAPECHAR} | {SYMBOLS} | {CHARACTERS})*')
You would do well to read the Flex manual chapter on patterns syntax. It is not very long, and it gives a complete description of the syntax of Flex patterns.
Here are a few of the errors you have made:
Flex patterns cannot include unquoted whitespace (unless you put them inside of a subexpression marked with the x flag). So
[\n] | [\t] | [\r] | [\] | ['] | ["]
is invalid.
Also, the \ is used to indicate that:
the following letter is a code for a control character (so that \n is a newline character), or
the following punctuation symbol should not be given special significance.
So in [\], the \ indicates that the following ] should be treated as an ordinary character, instead of being the end of a character class, which means that the character class will continue up to the next ]. Space characters inside a character class are considered to be quoted, so the character class consists of the characters ], space, |, [ and '. (Flex lets you repeat characters inside a character class, so it won't complain about the fact that there are two space characters.) You probably meant [\\].
Anyway, you should write character classes in the same way you wrote the other character classes, as a series of characters or escaped codes inside [ and ]:
[\n\t\r\\ '"]
Flex lets you quote characters by surrounding them with quotation marks, so that `"({ESCAPECHAR} | {SYMBOLS} | {CHARACTERS})*" is treated as a single literal string, which must be matched literally in the text. You probably intended the quotation marks to be ordinary characters, so you should have escaped them or put them into a single-character character class:
["]({ESCAPECHAR}|{SYMBOLS}|{CHARACTERS})*["]
Again, it is necessary to remove the whitespace from the pattern.
I assume that your intention was to allow "escape characters" to appear in a string only if they are actually escaped. Your {ESCAPECHAR} macro expands to a collection of actual characters, so that it includes newline, tab and carriage return characters. It also includes quote and apostrophe, which really should be reserved for terminating the string literal. Probably, what you meant was to allow escape codes if they are preceded with a \ (as with C or, as mentioned above, flex itself). In that case, what you really need to write is
ESCAPECHAR \\[ntr'"]
(That is, a \\, followed by exactly on of the characters n, t, r, ', ".) Even that is not precise, though: It does not allow the use of \\ to indicate a single \, and it forces the user to write "Don\'t just copy code." and '\"', both of which would normally be written without the backslash escapes.
Lets say I have a list of elements.
l = ["xf3", "x03", "x8c"] etc.
Now I would like to join the elements inside my list with a "\". I tried r"\".join(l) but it didn't work.
\ is used to escape 'special' characters, hence a Python string can not terminate with a single \ because it escapes the closing quote.
You have to escape it by using a second \, ie '\\'.join(l)
l = ["xf3", "x03", "x8c"]
'\\'.join(l)
The important part is to escape the '\\' as inn Python Strings:
the backslash "\" is a special character, also called the "escape"
character. It is used in representing certain whitespace characters:
"\t" is a tab, "\n" is a newline, and "\r" is a carriage return. As well "\"
can be used to escape itself: "\" is the literal backslash character.
I'm assuming is what you actually want is to create a string containing those escaped characters. The easiest way I can think of is ast.literal_eval:
>>> import ast
>>> ast.literal_eval("'\\" + "\\".join(l) + "'")
'รณ\x03\x8c'
This works by first creating a string of those strings joined by backslash characters (xf3\x03\x8c), surrounding those by quotes and adding the initial backslash ('\xf3\x03\x8c'), and finally, by evaluating it as a literal, to turn it from a length 12 string into a length 3 string.
How to replace many character with their CAPITALIZED form in a string/array in iMacros ( a to A , b to B etc)
hopely i can get my problem with imacros.. i just wanna do :
tag 1 is abcd, and i want replace it with ABCD (capital).
for replace many character to one character usualy i use this code
" SET !EXTRACT EVAL("'{{!EXTRACT}}'.replace(/[():;?!': '' ']/g, '-');") "
its mean replace char / [ \ ( \ ) : ; ? ! to " - "
but how to replace per character like a to A, b to B (capital)
thanks for your attention..
I'm barely starting to use iMacros, but i found your question looking to answer one of my own, and shortly afterwards I found this in the wiki:
Manipulate extraction
Transform extraction to uppercase characters:
VERSION BUILD=7400919 RECORDER=FX
TAB T=1
URL GOTO=http://android-developers.blogspot.com/2011/09/preparing-for-handsets.html
SET !EXTRACT_TEST_POPUP NO
TAG POS=1 TYPE=P ATTR=TXT:Early<SP>this<SP>year,* EXTRACT=TXT
SET !VAR1 EVAL("var s=\"{{!EXTRACT}}\"; s.toUpperCase()")
PROMPT {{!VAR1}}
This is the page:
http://wiki.imacros.net/EVAL
Hope it helps.
If someone will need to capitalize only first letter of each word (for me it looks not possible to do with just regex \U$1):
SET !EXTRACT EVAL("var s=\"{{!EXTRACT}}\"; s.replace(/(^\w|\s\w)/g, m => m.toUpperCase());")
How can I test my string as if it is a quote (") or not.
The default escape character is '^', isn't it?
So I tried the following but with no success yet:
if "!first_char!" == "^"" (...)
I tried double quote, too:
if "!first_char!" == """" (...)
Thanks!
The problem is not with the right part of the comparison, but with the left part. As first_char contains a quote, then the left operand of the comparison does not make sense. So you have to escape with ^ the variable that holds the ".
try something like this...
if .^!first_char!.==.^". (#echo ^!first_char! YES) else (#echo ^!first_char! NO)
The problem is only on the right part of the comparision.
The delayed expansion on the left side is always safe.
So you could simply use also a delayed expansion on the right side, like
set singleQuote="
if "!first_char!" == "!singleQuote!" (...)
Or alternativly you could escape all quotes.
if "!first_char!" == ^"^"^" (...)