quotes

Getting rid of double quotes inside array without turing array into a string [closed]

被刻印的时光 ゝ 提交于 2020-01-06 03:55:13
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I have an array x=["1", "2", "3", ":*", ":+", "4", "5", ":-", ":/"] I'm trying to get rid of the double quotation inside of the array. I know I can use: x.to_s.gsub('"','') and it will output a string: "[1, 2, 3, :*, :+, 4, 5, :-, :/]" The desired output I want is an array not a string: [1, 2, 3, :*, :+, 4, 5, :

expand arguments from array containing double quotes

柔情痞子 提交于 2020-01-05 02:31:32
问题 I want to call a program with arguments built from an array in bash. I want bash to call: echo -arg1=simple -arg2="some spaces" from array=(echo -arg1=simple "-arg2=\"some spaces\"") or similar (I can adjust the way the items are created). Problem With "${array[@]}" bash calls: echo -arg1=simple '-arg2="some spaces"' But I do not want the single quotes. How to build and expand the array correctly? Example code #!/bin/bash set -x array=() array+=(echo) array+=(-arg1=simple) array+=("-arg2=\

How to get rid of enclosing double-quotes in the expanded `forfiles` variables?

坚强是说给别人听的谎言 提交于 2020-01-04 16:57:34
问题 The forfiles command establishes several variables, indicated by a leading @ , which return data concerning the currently iterated item to the loop body. All the variables related to the path and name of the iterated item return the value enclosed in "" . Those are: @file , @fname , @ext , @path and @relpath . So: how can you get rid of the enclosing double-quotes? For example, the following code returns relative paths to text files in the given root directory: forfiles /P "C:\root" /M "*.txt

PHP-generated javascript and quote marks

主宰稳场 提交于 2020-01-03 04:35:15
问题 I'm generating some javascript in my PHP code, and I need to assign some php variables to javascript variables. Unfortunately, sometimes my PHP variables contain quote marks. for instance: $foo = "'Dis here be a \"string\""; print "<script type='text/javascript'>var foo = '{$foo}';</script>"; will generate a javascript error because the resulting javascript will look like this: <script type='text/javascript'>var foo = '"'Dis here be a \"string\"'; I know I can use regexp on $foo to replace

Why doesn't a command with quoted whitespace work when passed over ssh?

旧巷老猫 提交于 2020-01-03 03:19:25
问题 I am building this project in which I have to execute UNIX commands using ssh. Here is my question : When I execute the following command in a UNIX shell, echo "Hello World" It produces the output : Hello World With 5 spaces in between as the arguments were given within double quotes. I want to achieve the same effects with ssh as well. I am trying to escape the double quotes using backslash as follows : ssh localhost echo \"Hello World\" as I do not want bash to process the quotes. But it

Why doesn't a command with quoted whitespace work when passed over ssh?

谁说我不能喝 提交于 2020-01-03 03:19:08
问题 I am building this project in which I have to execute UNIX commands using ssh. Here is my question : When I execute the following command in a UNIX shell, echo "Hello World" It produces the output : Hello World With 5 spaces in between as the arguments were given within double quotes. I want to achieve the same effects with ssh as well. I am trying to escape the double quotes using backslash as follows : ssh localhost echo \"Hello World\" as I do not want bash to process the quotes. But it

Using python csv writer without quotations

安稳与你 提交于 2020-01-01 04:57:26
问题 I'm trying to write a list of strings like below to a file separated by the given delimiter. res = [u'123', u'hello world'] When I try splitting by TAB like below it gives me the correctly formatted string. writer = csv.writer(sys.stdout, delimiter="\t") writer.writerow(res) gives --> 123 hello world But when I try to split by space using delimiter=" " , it gives me the space but with quotation marks like below. 123 "hello world" How do I remove quotation marks. So that when I use space as

Using python csv writer without quotations

吃可爱长大的小学妹 提交于 2020-01-01 04:57:07
问题 I'm trying to write a list of strings like below to a file separated by the given delimiter. res = [u'123', u'hello world'] When I try splitting by TAB like below it gives me the correctly formatted string. writer = csv.writer(sys.stdout, delimiter="\t") writer.writerow(res) gives --> 123 hello world But when I try to split by space using delimiter=" " , it gives me the space but with quotation marks like below. 123 "hello world" How do I remove quotation marks. So that when I use space as

Escaping a quote in findstr search string

我与影子孤独终老i 提交于 2020-01-01 04:51:06
问题 How can I properly escape a quote in a search string when using findstr.exe? Example: findstr /misc:"namespace=\"" *.cs > ns.txt This outputs to the console, instead of to the file I specified. I am doing this directly on the command line, not actually in a batch file, though that information might be useful too. 回答1: Please correct me if I'm wrong, but I think I've figured it out: findstr.exe /misc:^"namespace=\^"^" *.cs > ns.txt This seems to give the correct output, even if you have spaces

PowerShell: Quoting -replace & variables

浪子不回头ぞ 提交于 2019-12-30 03:55:08
问题 This is in response to my previous question: PowerShell: -replace, regex and ($) dollar sign woes My question is: why do these 2 lines of code have different output: 'abc' -replace 'a(\w)', '$1' 'abc' -replace 'a(\w)', "$1" AND according to the 2 articles below, why doesn't the variable '$1' in single quotes get used as a literal string? Everything in single quotes should be treated as a literal text string, right? http://www.computerperformance.co.uk/powershell/powershell_quotes.htm http:/