string-manipulation

Splitting strings in a "Google" style way

I am trying to create a function that will split a string into search terms. Using this code will work fine: string TestString = "This is a test"; string[] Terms; Terms = TestString.Split(" "); This will split my string into 4 strings: "This", "is", "a", "test". However I want words that are enclosed in quotes to be treated as one wor...

How do I extract certain digits from raw input in Python?

Let's say I ask a users for some random letters and numbers. let's say they gave me 1254jf4h. How would I take the letters jfh and convert them inter a separate variable and then take the numbers 12544 and make them in a separate variable? ...

Adding formatting support to a custom string implementation - C

I have a C application (not using C99 features) that does some heavy string processing. Since the string lengths are not known, statically allocated buffers is not an option for me. I have created a simple string implementation which will abstract the null termination and dynamic expansion of buffers. Here is how it looks like, struct ...

Find duplicate strings in a large file

A file contains a large number (eg.10 billion) of strings and you need to find duplicate Strings. You have N number of systems available. How will you find duplicates ...

How do I extract a substring from a string in Jquery

Hi, I want to write a message in a textarea and be able to refer to a person using the @ symbol. e.g Please call @Larry David regarding something When submitting the form, I want to extract the persons name ie Larry David. How do I go about extracting this string with Jquery? ...

converting string into multidimensional array

hi, I'd like to convert this string: $credit_packages_string = "300,0.25|1000,0.24|3000,0.22|4000,0.20|5000,0.18|6000,0.16|7000,0.14"; into this array: $credit_packages = array( array( 'credit_amount'=> 300, 'price_per_credit'=>0.25), array( 'credit_amount'=> 1000, 'price_per_credit'=>0.24), array( 'credit...

How do they search inside a string

What is the most efficient way to do this? There must be some better method other than brute force. ...

How to find a common suffix in two strings?

I'm trying to implement something that finds the common suffix between a number of strings, for the sake of illustrations, consider the following: "The quick brown fox" "The not so quick brown fox" "The smelly brown fox" "The vicious brown fox" To a human, it's hopefully obvious that the common suffix here is " brown fox", and my nai...

String Manipulation Methods giving RunTime Error.

This seems to be giving me a bit of trouble. This method is supposed to generate a random number and assigns it to a char. getline grabs the entire string from the text file and assigns it to foods. y has the purpose of holding the place of where it finds c in the foods string. It will then use that int to erase from the string and prin...

Get leading whitespace

Hi, I just wrote this method and I'm wondering if something similar already exists in the framework? It just seems like one of those methods... If not, is there a better way to do it? /// <summary> /// Return the whitespace at the start of a line. /// </summary> /// <param name="trimToLowerTab">Round the number of spaces down to the ne...

Groovy split() method bug ?

Hi, The following Groovy snippet produces weird results to me : def s = "123456" assert s.split("").size() == s.size() Results in : Assertion failed: assert s.split("").size() == s.size() | | | | | | | | 7 | | 6 | | | 123456 | | false | [,...

Last word in a sentence: In SQL (regular expressions possible?)

I need this to be done in Oracle SQL (10gR2). But I guess, I would rather put it plainly, any good, efficient algorithm is fine. Given a line (or sentence, containing one or many words, English), how will you find the last word of the sentence? Here is what I have tried in SQL. But, I would like to see an efficient way of doing this. ...

Using C#, how can I replace similar words?

Hi, Assuming these two strings: string s1="control"; string s2="conrol"; (or "ocntrol", "onrtol", "lcontro" etc.) How can I programatically find that s2 is similar with s1 and replace the s2 string with the s1 string? Thanks. Jeff ...

Parsing a large CSV file, dealing with commas and quotes

I need to load in a large CSV file (>1MB) and parse it. Generally this is quite easy to do by splitting first on linebreaks and then commas. The problem is though that some entries contain Strings that include their own commas. When this spreadsheet is converted to CSV, the lines containing commas are wrapped in quotes. I've written a ...

how to replace \ with \\ using javascript string functions

I have the following filepath var imagepath="C:\Documents and Settings\Mahesh\Desktop\images\advts.png" how can i replace \ with \ so so that it prints var imagepath="C:\\Documents and Settings\\Mahesh\\Desktop\\images\\advts.png" ...

Split a string in python

a="aaaa#b:c:" >>> for i in a.split(":"): ... print i ... if ("#" in i): //i=aaaa#b ... print only b In the if loop if i=aaaa#b how to get the value after the hash.should we use rsplit to get the value? ...

How to convert this string manipulation function UTF-8 Compatible in PHP?

Good day, I had trouble finding a function that does exactly what I am looking for. Unfortunatly, this function isn't UTF-8 Compatible. This functions is like a basic ucwords but it also do the uppercase on a character followed by one of the given characters found (in my case I need to apply an uppercase on the character found after a -...

String Replace operation in GWT 2.0.4

I am using GWT 2.0.4 and want to perform the trivial operation of replacing string. Something which can be done using java.lang in java, and since GWT doesn't support Java libraries and I want to avoid writing a JSNI, is there a way to do a string replace, Is there anything i am missing or might not knw? Latest version of GWT,which is j...

R Programming: Automating Merge of Character Strings

Hi there, I'm trying to automate some of the systems at work here specifically to do with report generation based on survey data. Lets say i have 3 comments for 1 question. current_comments <- c("too slow", "not fast enough", "bad speed") Basically what i want to do is merge the comments into one string separated by a "-" too look ...

sed: How do I replace all lines containing a certain string?

Say I have a file containing these lines: tomatoes bananas tomatoes with apples pears pears with apples How do I replace every line containing the word "apples" with just "oranges"? This is what I want to end up with: tomatoes bananas oranges pears oranges ...