quotes

Stripping single and double quotes in a string using bash / standard Linux commands only

徘徊边缘 提交于 2019-12-03 09:38:35
问题 I'm looking for something that will translate a string as follows, using only bash / standard Linux commands: Single-quotes surrounding a string should be removed Double-quotes surrounding a string should be removed Unquoted strings should remain the same Strings with unmatched surrounding quotes should remain the same Single-quotes that don't surround the string should remain Double-quotes that don't surround the string should remain For example: 'Food' should become Food "Food" should

Using YQL multi-query & XPath to parse HTML, how to escape nested quotes?

好久不见. 提交于 2019-12-03 08:27:44
The title is more complicated than it has to be, here's the problem query. SELECT * FROM query.multi WHERE queries=" SELECT * FROM html WHERE url='http://www.stumbleupon.com/url/http://www.guildwars2.com' AND xpath='//li[@class=\"listLi\"]/div[@class=\"views\"]/a/span'; SELECT * FROM xml WHERE url='http://services.digg.com/1.0/endpoint?method=story.getAll&link=http://www.guildwars2.com'; SELECT * FROM json WHERE url='http://api.tweetmeme.com/url_info.json?url=http://www.guildwars2.com'; SELECT * FROM xml WHERE url='http://api.facebook.com/restserver.php?method=links.getStats&urls=http://www

Quotes when using grep?

扶醉桌前 提交于 2019-12-03 07:58:36
问题 Grep acts differently depending on what kind of quotes I surround the regex with. I can't seem to get a clear understanding of why this is. Here is an example of the problem: hamiltont$ grep -e show\( test.txt variable.show(); variable.show(a); variable.show(abc, 132); variableshow(); hamiltont$ grep -e "show\(" test.txt grep: Unmatched ( or \( hamiltont$ grep -e 'show\(' test.txt grep: Unmatched ( or \( I am just assuming there is some proper way to enclose the regex with single/double

Bash quoted array expansion

ぃ、小莉子 提交于 2019-12-03 07:47:57
问题 WHen I write a bash program I typically construct calls like follows: declare -a mycmd=( command.ext "arg1 with space" arg2 thing etc ) "${mycmd[@]}" || echo "Failed: foo" Where die foo is a bash function that prints Error foo and exits. But if I want to be clear about the error reason, I want to print the failed command: "${mycmd[@]}" || echo "Failed: foo: ${mycmd[*]}" So the user can run the dead command and find out why . However, quoting is lost on this pass - the Failed message arguments

HTML5: which is better - using a character entity vs using a character directly?

拜拜、爱过 提交于 2019-12-03 06:40:20
问题 I've recently noticed a lot of high profile sites using characters directly in their source, eg: <q>“Hi there”</q> Rather than: <q>“Hi there”</q> Which of these is preferred? I've always used entities in the past, but using the character directly seems more readable, and would seem to be OK in a Unicode document. 回答1: If the encoding is UTF-8, the normal characters will work fine, and there is no reason not to use them. Browsers that don't support UTF-8 will have lots of other issues while

Python shlex.split(), ignore single quotes

跟風遠走 提交于 2019-12-03 06:18:44
How, in Python, can I use shlex.split() or similar to split strings, preserving only double quotes? For example, if the input is "hello, world" is what 'i say' then the output would be ["hello, world", "is", "what", "'i", "say'"] . import shlex def newSplit(value): lex = shlex.shlex(value) lex.quotes = '"' lex.whitespace_split = True lex.commenters = '' return list(lex) print newSplit('''This string has "some double quotes" and 'some single quotes'.''') You can use shlex.quotes to control which characters will be considered string quotes. You'll need to modify shlex.wordchars as well, to keep

Should I use single or double quotes in my .vimrc file?

半城伤御伤魂 提交于 2019-12-03 05:17:24
What’s the difference between single ( ' ) and double ( " ) quotes in Vim? Does it make speed differences? Is it better to use one or another when running functions inside it? Does it matter at all? I’m interested specifically in their use in the .vimrc file. I’m asking because I find people use both in the same thing, and I’m wondering what are the differences. I tried to Google this, but wasn’t able to find anything. Eric Mathison Double quotes allow for interpolation whereas single quotes do not. For example, using double quotes :echo "foo\nbar" will output foo and bar on separate lines

When to use triple single quotes instead of triple double quotes

℡╲_俬逩灬. 提交于 2019-12-03 04:14:53
问题 Learn Python the hard way, exercise 10.2: tabby_cat = "\tI'm tabbed in." persian_cat = "I'm split\non a line." backslash_cat = "I'm \\ a \\ cat." fat_cat = """ I'll do a list: \t* Cat food \t* Fishies \t* Catnip\n\t* Grass """ print tabby_cat print persian_cat print backslash_cat print fat_cat 2: Use ''' (triple-single-quote) instead. Can you see why you might use that instead of """ ? I can't see why I might use ''' instead of """ . It gives me the same output. Can someone explain me why I

How can one turn regular quotes (i.e. ', \") into LaTeX/TeX quotes (i.e. `', ``'')

好久不见. 提交于 2019-12-03 03:43:55
Given a document written with normal quotes, e.g. Ben said "buttons, dear sir". I replied "Did you say 'buttons'?" to him. What ways can one turn these sort of things into LaTeX quotes, with the appropriate semantics. i.e. Ben said ``buttons, dear sir''. I replied ``Did you say `buttons'?'' to him. So that LaTeX produces: Ben said “buttons, dear sir”. I replied “Did you say ‘buttons’?” My first thought is to turn to a regex. However, I'm not getting any hits from Google or the regex libraries for "LaTeX quotes regular expression", and of course "TeX quotes regular expression" seems to return

Remembering a quote from Alan Kay

巧了我就是萌 提交于 2019-12-03 00:02:01
问题 Locked . This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions. Alan Kay was quoted several years ago to the effect that there had been only three new things in software in the preceding 20 years (effectively the lifespan of PCs). One of them was Spreadsheets. Does anyone remember the other two? Who is Alan Kay? (a few may ask.) His work at Xerox Parc arguably did more to shape our