quotes

JavaScript HERE-doc or other large-quoting mechanism?

萝らか妹 提交于 2019-11-27 01:49:35
问题 Is there a convenient way to quote a large block of HTML that has both single and double quotes in JavaScript? Is there anything like a HERE-doc <<EOF , a multi-quote character """ , or custom delimiters q{} ? Any creative or inventive solutions to this problem? 回答1: Some people don't like this, so be prepared for scorn and derision, but one trick is to dump your "big block of stuff" into a <script language="text"> block: <script id='blockOfStuff' language="text"> Hi this is random stuff <h1

How do I remove quotes from a string?

夙愿已清 提交于 2019-11-27 01:27:14
问题 $string = "my text has \"double quotes\" and 'single quotes'"; How to remove all types of quotes (different languages) from $string ? 回答1: str_replace('"', "", $string); str_replace("'", "", $string); I assume you mean quotation marks? Otherwise, go for some regex, this will work for html quotes for example: preg_replace("/<!--.*?-->/", "", $string); C-style quotes: preg_replace("/\/\/.*?\n/", "\n", $string); CSS-style quotes: preg_replace("/\/*.*?\*\//", "", $string); bash-style quotes: preg

Properly handling spaces and quotes in bash completion

亡梦爱人 提交于 2019-11-27 01:17:09
问题 What is the correct/best way of handling spaces and quotes in bash completion? Here’s a simple example. I have a command called words (e.g., a dictionary lookup program) that takes various words as arguments. The supported ‘words’ may actually contain spaces, and are defined in a file called words.dat : foo bar one bar two Here’s my first suggested solution: _find_words() { search="$cur" grep -- "^$search" words.dat } _words_complete() { local IFS=$'\n' COMPREPLY=() cur="${COMP_WORDS[COMP

Remove quotes from a character vector in R

浪子不回头ぞ 提交于 2019-11-27 00:37:30
Suppose you have a character vector: char <- c("one", "two", "three") When you make reference to an index value, you get the following: > char[1] [1] "one" How can you strip off the quote marks from the return value to get the following? [1] one as.name(char[1]) will work, although I'm not sure why you'd ever really want to do this -- the quotes won't get carried over in a paste for example: > paste("I am counting to", char[1], char[2], char[3]) [1] "I am counting to one two three" Just try noquote(a) noquote("a") [1] a There are no quotes in the return value, only in the default output from

How does the leading dollar sign affect single quotes in Bash?

北战南征 提交于 2019-11-27 00:08:21
问题 I need to pass a string to a program as its argument from the Bash CLI, e.g program "don't do this" The string may include any character like '$' , '\' , etc. and I don't want Bash to do any modification. So I think about using single quotes. However the following does not work: program 'don\'t do this' //escape doesn't work in single quote While the following two works: program $'dont\'t do this' //seems fine, but any other side effects? program 'dont'\''do this' //breaking into 3 parts The

How can i parse a comma delimited string into a list (caveat)?

扶醉桌前 提交于 2019-11-26 22:56:44
问题 I need to be able to take a string like: '''foo, bar, "one, two", three four''' into: ['foo', 'bar', 'one, two', 'three four'] I have an feeling (with hints from #python) that the solution is going to involve the shlex module. 回答1: The shlex module solution allows escaped quotes, one quote escape another, and all fancy stuff shell supports. >>> import shlex >>> my_splitter = shlex.shlex('''foo, bar, "one, two", three four''', posix=True) >>> my_splitter.whitespace += ',' >>> my_splitter

PyYAML dump format

只愿长相守 提交于 2019-11-26 22:47:26
问题 I know there are a few questions about this on SO, but I couldn't find what I was looking for. I'm using pyyaml to read ( .load() ) a .yml file, modify or add a key, and then write it ( .dump() ) again. The problem is that I want to keep the file format post-dump, but it changes. For example, I edit the key en.test.index.few to say "Bye" instead of "Hello" Python: with open(path, 'r', encoding = "utf-8") as yaml_file: self.dict = pyyaml.load(yaml_file) Then, afther changing the key: with open

How to use single quote inside an echo which is using single quote

若如初见. 提交于 2019-11-26 22:45:45
First of all, i have gone through the related questions.. haven't found any answer.. I m using this code to display a message echo 'Here goes your message with an apostrophe S like thi's '; How can i make this work, as any quote inside this echo will break the statement... Either escape the quote with a backslash, or use double quotes to designate the string. echo 'Here goes your message with an apostrophe S like thi\'s'; echo "Here goes your message with an apostrophe S like thi's"; He Hui Escape the quote using a backslash. 'hello\'s' The single quote that appears after the backslash will

How to call execl() in C with the proper arguments?

匆匆过客 提交于 2019-11-26 22:39:48
i have vlc (program to reproduce videos) if i type in a shell: /home/vlc "/home/my movies/the movie i want to see.mkv" it opens up an reproduces the movie. however, when I run the following program: #include <unistd.h> int main(void) { execl("/home/vlc", "/home/my movies/the movie i want to see.mkv",NULL); return 0; } vlc opens up but doesn't reproduce anything. How can I solve this? Things I tried: I guessed execl("/home/vlc", "/home/my movies/the movie i want to see.mkv",NULL); was equivalent to typing in the shell: /home/vlc /home/my movies/the movie i want to see.mkv which doesn't work, so

How to create cookie without quotes around value?

烈酒焚心 提交于 2019-11-26 22:08:38
问题 I need to create cookie with e-mail address as value - but when I try to - then I have result: "someone@example.com" but I would like to have: someone@example.com The cookie should be created without double quoted marks - because other application uses it in such format. How to force java to not to add double quoted? Java adds them because there is special char "at". I create the cookie that way: HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance()