Bash: Concatenate all arguments and wrap them with double quotes
function foo() { A=$@... echo $A } foo bla "hello ppl" I would like the output to be: "bla" "hello ppl" What do I need to do instead of the ellipsis? ...
function foo() { A=$@... echo $A } foo bla "hello ppl" I would like the output to be: "bla" "hello ppl" What do I need to do instead of the ellipsis? ...
I would like to read strings into Matlab from an excel file ID = xlsread('data.xlsx',1, 'D2:D4') the cells in range D2:D4 have strings in them. When I try to import the strings into Matlab all I get is an empty list? what can I do to fix this? ...
I've been running across a lot of Perl code that breaks long strings up this way: my $string = "Hi, I am a very long and chatty string that just won't"; $string .= " quit. I'm going to keep going, and going, and going,"; $string .= " kind of like the Energizer bunny. What are you going to"; $string .= " do about it?"; From my backgr...
I am writing a cell array of string into Excel from Matlab. I have a cell array data{} that I am trying to write into Matlab. It should writting three large lengths of strings to excel since the strcmp passes 3 times. Currently it is only writing the last set of strings into excel. data = { {1x25} {1x35} {1x20} } looks like this. Also I ...
I was using the TrimStart function to do the following: var example = "Savings:Save 20% on this stuff"; example = example.TrimStart("Savings:".ToCharArray()); I was expecting this to result in example having a value of "Save 20% on this stuff". However, what I got was "e 20% on this stuff". After reading the documentation on TrimSta...
I'm trying to wrap my head around the best way to do a templating system for my PHP CMS. I'm a little stuck and so I'm looking for a few suggestions or ideas. Here is my desired setup: Each page is composed of various widgets (or content blocks, if you prefer). Each widget has an MVC architecture, with the View being simple, composed of...
I'm writing a program that searches directories of a computer. On my own computer I have a drive installed which previously booted Windows Vista. (However, there are drives that do not appear even when "show hidden folders". I can see the folders running cmd, but that doesn't solve my problem.) I don't care so much about the folders...
I'm trying to pull the two components out of a timeval struct and place them into strings. I'm not having much luck with this. I've attempted casting and converting first to a long and then to a string. I need the most efficient way to do this. Any ideas? I do NOT want to convert to another data structure first (localtime, etc). I need...
Today I noticed that C#'s String class returns the length of a string as an Int. Since an Int is always 32-bits, no matter what the architecture, does this mean that a string can only be 2GB or less in length? A 2GB string would be very unusual, and present many problems along with it. However, most .NET api's seem to use 'int' to con...
I've been researching on finding an efficient solution to this. I've looked into diffing engines (google's diff-match-patch, python's diff) and some some longest common chain algorithms. I was hoping on getting you guys suggestions on how to solve this issue. Any algorithm or library in particular you would like to recommend? Thanks. ...
Firstly, is there one? If not, is there a nice way to force something like print '%s' % obj to call obj.__unicode__ instead of obj.__str__? ...
I am using PHP and I am looking to create links within my text to other sections of the site so for example: I fell into the media industry aged 30, when David Mansfield, now on the board of Ingenious Media, gave me my first break at Thames TV. From there, I worked at the (now-defunct) Sunday Correspondent and IPC, before joining TDI, w...
I have an array in javascript that contains the following: ["Value 1", "Value 5". "Value 10", "Value 11"]; How would I go about sort this array so that it does not appear as follows: ["Value 1", "Value 10". "Value 11", "Value 5"]; But as: ["Value 1", "Value 5". "Value 10", "Value 11"]; Any help would be great. ...
Hi, how can I make this not return an error of: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING . $day[$i++] = "<tr><?php if(isset($schedule['00:00'])) { ?><td style=\"width:32px\"><?php echo $schedule['00:00'] ?></td><?php } if(isset($schedule['02:00'])) { ?><td style...
(Sorry! Revision regarding the $ character. Explaining via example as well) I need to run a test on two string variables: $a, $b If $a is contained in $b, I need to see if their "difference" ($b-$a) contains the $ character in it. If it does, then return the "difference", else in all other cases, the test should return FALSE Also $a ...
Is there any facility in the standard Java libraries that, given a CharSequence, produces the reverse in O(1) time? I guess this is "easy" to implement, just wondering whether it already exists. (I suspect the reason this is not offered is because the "easy" way would actually break multi-char code-points - but in many cases we know we...
I have a string as follows: names = "name:fred, name:wilma, name:barney, name2:gauss, name2:riemann" let's say the string names has name and name2 attributes. How do I write a function, is_name_attribute(), that checks if a value is a name attribute? That is is_name_attribute('fred') should return True, whereas is_name_attribute('gau...
In my travels in Oracle, the 'stragg' function, or 'String Aggregator' was life-saving when I had to create dynamic SQL queries on the fly. You can read up about it here: http://www.oratechinfo.co.uk/delimited_lists_to_collections.html The basic use of it was: select stragg(fruit) from food; fruit ----------- apple,pear,banana,strawb...
I have an object array, I know that the elements are type String, say I need to access them many times. Practice 1: access the element by array index and cast it to String every time I need it. Practice 2: create local String instances and access each of the elements once. Which will run faster? If it's on a mobile device where memor...
Hi all, This is the exercise in "Introduction to The Design and Analysis of Algorithms". It's a string matching issue. Say I have string ABCD, and have a pattern XY. And want to see if the string contains the pattern. We just assume to use brute-force here, so the left-to-right comparison is comparing A with X, next is comparing B with...