string-manipulation

C# - Easiest way to parse filename with spaces eg. "C:\Test\File with spaces.txt"

I am trying to pass a full file path to FFMPEG. C:\TestFolder\Input\Friends - Season 6 - Gag Reel.avi and it's obviously not liking the fact the path has spaces in it, erroring like so: C:\TestFolder\Input\Friends: no such file or directory So what's the easiest way to use filenames with spaces in them? Should I just replace all ...

Creating a MySQL SET's from a string

Is there a way to create a set from a string of separated values in MySQL? For example: 'the,quick,brown,fox' => 'the','quick','brown','fox' A sort of inverse EXPORT_SET without the bit fiddeling. Regards ...

Loose dictionary, need advice

I need to create a dictinary where key is string and value is Object. But I don't want exact match of the key with user provided string. Instead I want to key to contain a part of string. Let me explain by example If there is an entry in dictionary under key "Johnson" I want to be able to find value given input strings "John", "Jo". Als...

Concat over '+' operator for string concatenation

String today = someSimpleDateFormat.format(new Date()); Calendar rightNow = Calendar.getInstance(); int hour = rightNow.get(Calendar.HOUR_OF_DAY); int minute = rightNow.get(Calendar.MINUTE); String hourString = String.valueOf(hour); String minuteString = String.valueOf(minute); if(hourString.length() == 1){ hourString = '0'.concat(h...

convert values in string to float array

i have a string in C which i got from some algorithm. it has numeric values in a format like this 0.100 0.840 0.030 0.460 0.760 -0.090 and so on in need to store each of these numeric values into a float array for numeric processing. i am new to C and found string handling in C to be complex. can anyone tell me how i might implement ...

extracting substrings in C

I have the string: "foo$bar@baz" I'm looking to write a C program which will extra all three sub-strings ("foo", "bar" and "baz") and put each into it's own string. P.S. Don't worry, this is not homework. ...

Public implementation of ropes in C#?

Is there a public implementation of the Rope data structure in C#? ...

Is there any scenario where the Rope data structure is more efficient than a string builder

Related to this question, based on a comment of user Eric Lippert. Is there any scenario where the Rope data structure is more efficient than a string builder? It is some people's opinion that rope data structures are almost never better in terms of speed than the native string or string builder operations in typical cases, so I...

Removing an element from a list based on a predicate

I want to remove an element from list, such that the element contains 'X' or 'N'. I have to apply for a large genome. Here is an example: input: codon=['AAT','XAC','ANT','TTA'] expected output: codon=['AAT','TTA'] ...

Java: Regex replacing

Hi, I have this String: foo bar 567 baz Now I want to add before each number the String num:. So the result has to be: foo bar num:567 baz Also this has to work: foo 73761 barbazboom!! 87 result: foo num:73761 barbazboom!! num:87 The regex to search number is this: [0-9]+ But I want to replace the matching substring with num: +...

IndexOf function in t-Sql

Given an email address column, I need to find the position of the @ sign for substringing. What is the indexof function, for strings in t-sql. Looking for something that returns the position of a substring within a string. in c# var s = "abcde"; s.IndexOf('c'); // yields 2 ...

Grab HTML code from web

I'm working on a project for fun but i want to grab just the html code from a website which I will later have to extract just the links. I've been googling for a few minutes and I haven't found anything that does what I want specifically (just the text). ...

String Manipulation in SQL Server

Is there any way of setting an "Column Alias" in SQL Server? For Example i have two columns. Description and Price ID colDescription colPrice 1 Red ball costs %colPrice% dollars 2 2 Blue ball costs %colPrice% dollars 3 The selection of colDescription for ID=2, should fe...

Capitalize Element Name in XSL

I am writing a XSL transformation and my source has an element like this - "title". The target xml should contain "Title". Is there a way to capitalize the first letter of a string in XSL? ...

String Conversion

Hi i have string s='This is sample' i need to convert like this s='"This is sample"' output="This is sample" how to do this in dynamic Thanks in advance ...

string.Compare behavior

How this can be ? (This is taken from the immediate window in VS2008) ?string.Compare("-", "+") -1 ?string.Compare("-0", "+0") 1 ...

PHP string manipulation

I'm reading a textfile on the format Phone#(tab)Text(line break) (line break) Or more specifically 4799999999 Hey! You owe us $576.53. Pay up to account no. 9760.00.12345, ID: 201561438. 4798888888 Hey! You owe us $199. Pay up to account no. 9760.05.12345, KID: 201565173. 4797777777 Hey! You owe us... and so on. I want to store...

Homework: Java IO Streaming and String manipulation

In Java, I need to read lines of text from a file and then reverse each line, writing the reversed version into another file. I know how to read from one file and write to another. What I don't know how to do is manipulate the text so that "This is line 1" would be written into the second file as "1 enil si sihT" ...

Explain Python .join()

I'm pretty new to Python and am completely confused by .join() which I have read is the preferred method for concatenating strings. I try: strid = repr(595) print array.array('c', random.sample(string.ascii_letters, 20 - len(strid))) .tostring().join(strid) and get something like: 5wlfgALGbXOahekxSs9wlfgALGbXOahekxSs5 Why does...

MySql Question - way to update portion of a string?

I'm looking for a way to update just a portion of a string via mysql query. For example, if I have 10 records all containing 'string' as part of the field value (i.e., 'something/string', 'something/stringlookhere', 'something/string/etcetera', is there a way to change 'string' to 'anothervalue' for each row via one query, so that the...