string-manipulation

How can I keep track of character positions after I remove elements from a string?

Let us say I have the following string: "my ., .,dog. .jumps. , .and..he. .,is., .a. very .,good, .dog" 1234567890123456789012345678901234567890123456789012345678901 <-- char pos Now, I have written a regular expression to remove certain elements from the string above, in this example, all whitespace, all periods, and all commas....

A string searching algorithm to quickly match an abbreviation in a large list of unabbreviated strings?

Hi! I am having a lot of trouble finding a string matching algorithm that fits my requirements. I have a very large database of strings in an unabbreviated form that need to be matched to an arbitrary abbreviation. A string that is an actual substring with no letters between its characters should also match, and with a higher score. E...

How can I build an incremental directed acyclic word graph to store and search strings?

Hi! I am trying to store a large list of strings in a concise manner so that they can be very quickly analyzed/searched through. A directed acyclic word graph (DAWG) suits this purpose wonderfully. However, I do not have a list of the strings to include in the first place, so it must be incrementally buildable. Additionally, when I sear...

String Manipulation in iPhone

Hi, I am having a lengthy string which contains alphabets and a special character like "|". i need to split this strings based on the "|" delimiter and store the individual string in to an array. Is there any string function which helps us to do the same.? Thanks, Shibin. ...

Capitalize / Capitalise first letter of every word in a string in Matlab?

What's the best way to capitalize / capitalise the first letter of every word in a string in Matlab? i.e. the rain in spain falls mainly on the plane to The Rain In Spain Falls Mainly On The Plane ...

using regex to remove comments from source files

So I'm new to python, (i wrote my first bit of code I it today) (I'm relitivly experienced in C, and decent in C++, Java and assember - if abit out of practice) I'm, making a program to automate the writing of some C code, (I'm writing to parse stigns into enumerations with the same name) C's handleing of stings is, well it's not that gr...

How to detect the passing of a string literal to a function in C?

I am trying to implement an eqivilent version of perl's chomp() function in C and I have come across a corner case where a string literal passed as the argument will cause a segmentation fault (rightfully so). Example chomp("some literal string\n"); Is there a defined way in C99 to detect wether or not my function was passed a string ...

How can I create variables at run-time based on names pulled from a string?

Hoping someone can assist and hoping this is possible in JavaScript. I basically have the following string in the format: A,B,C:D,E,F What I am trying to achieve is a means of pairing up left hand side JavaScript variable, to the left of the ":" with the right hand side values to the right of the ":" I basically would like to have the...

Last but one Char in vb.net String

How do I find last but one character in a vbstring for e.g. In the string V1245-12V0 I want to return V ...

objective c parse domain name from url string

Hi How would I parse a domain name in objective -c? For example if my string value was "http://www.google.com" I would like to parse out the string "google" ...

Convert dbus.String to normal string

I am using dbus to get the current playing song from Songbird Media Player & Metadata is also taken from dbus object. The line where error comes is:- audio_file = MP3(current_playing_track['location'], ID3=ID3) The error is:- Traceback (most recent call last): File "./last.py", line 42, in <module> audio_file = MP3(current_pl...

vb.net address parsing question

i need to parse normail mailing addresses in vb.net. the requirement is address shall be split in 2 variables. so if address is 12300 euclid st. then it will be "12300" and "euclid st." in two different variables. also if address is 123 B4 euclid st then "123 B4" and "euclid st". Sometimes address is 12008 B2 euclid st Apt 12. In this c...

SQL - Selecting portion of a string

If I have a simple table where the data is such that the rows contains strings like: /abc/123/gyh/tgf/345/6yh/5er In SQL, how can I select out the data between the 5th and 6th slash? Every row I have is simply data inside front-slashes, and I will only want to select all of the characters between slash 5 and 6. ...

rails break pasted code into lines and display

Lets say I have a rails application in which code is pasted into the content text box like the following. Pasted Code Person name Person name Person name Person name It is put into the database with the proper new lines after each line according to my server log. What I want to do is in the show action I want to output this text a...

Java: Finding birthdate on different planets

I'm writing a program that asks the user for their birthdate and then calculates that birthdate on different planets. I am not suppose to assume how the birthdate is to be enter except that there is one white space between each number. The code I have right now does not meet these specifications right now and I'm not sure how to write i...

using a key to rearrange string

Using Python I want to randomly rearrange sections of a string based on a given key. I also want to restore the original string with the same key: def rearrange(key, data): pass def restore(key, rearranged_data): pass Efficiency is not important. Any ideas? Edit: can assume key is hashable, but may be multiple types defin...

Check if a string is capitalized in Rails

I'm looking to check if a string is all capitals in Rails. How would I go about doing that? I'm writing my own custom pluralize helper method and I would something be passing words like "WORD" and sometimes "Word" - I want to test if my word is all caps so I can return "WORDS" - with a capital "S" in the end if the word is plural (vs. "...

Problem (un-)greedy RegExp

Consider the following Strings: 1: cccbbb 2: cccaaabbb I would like to end up with are matches like this: 1: Array ( [1] => [2] => bbb ) 2: Array ( [1] => aaa [2] => bbb ) How can I match both in one RegExp? Here's my try: #(aaa)?(.*)$# I have tried many variants of greedy and ungreedy modifications but it doe...

Insert line breaks in long string -- word wrap

Here is a function I wrote to break a long string into lines not longer than a given length strBreakInLines <- function(s, breakAt=90, prepend="") { words <- unlist(strsplit(s, " ")) if (length(words)<2) return(s) wordLen <- unlist(Map(nchar, words)) lineLen <- wordLen[1] res <- words[1] lineBreak <- paste("\n", prepend, sep...

Using JSON data

Hi. I am trying to make a simple twitter client in C. I'm new at this and not sure how to go about segregating meaningful stuff from the JSON string that I get from the API. For example, if I get this as a response from the API, how do I extract out the value of "text" into a string (char*)? I guess I can work with the string at low ...