string

Finding a substring in a NSString object

Hi, I have an NSString object and I want to make a substring from it, by locating a word. For example, my string is: "The dog ate the cat", I want the program to locate the word "ate" and make a substring that will be "the cat". Can someone help me out or give me an example? Thanks, Sagiftwenter code here ...

Replace a substring with another substring

Hi, I want to replace the string "abc" to "def" each time it appears in my NSString object: "axcd abc amamam dff abc kdj abc" How do I do that?? Thanks, Sagiftw ...

Is there another way to truncate a string?

char out_file_name[30]; ogSize = strlen(FileName); //i.e. - FileName_anylength.log (always.log) ogSize -= strlen(IN_FILE_SUFFIX); //amount of chars before .log strncpy( out_file_name, FileName, ogSize ); //out_file_name now is FileName_anylength (without the .log) Is this the best way to do this? Also, how do I guard that ogS...

Converting String to NSDate issue

Hello all, I have been looking over StackOverflow and have not found any answers yet, if I missed a post which answers this I apologize and would be grateful for the link. I am trying to change a string "prod.Start" into a NSDate type for comparison with today's date. The following code myDate returns "1753-01-01 00:00:00 -075258" CO...

Need help parsing strings in Java

Hello everyone, I am reading in a csv file in Java and, depending on the format of the string on a given line, I have to do something different with it. The three different formats contained in the csv file are (using random numbers): 833 "79, 869" "56-57, 568" If it is just a single number (833), I want to add it to my ArrayList. If ...

How do I search for words that begins and ends with other words from the same array?

I have a long list of words in an array. Some short, some long. I'd like to filter out those words which starts with a word from the array (length of this "prefix" word can be set to, say, 3 characters) and which at the same time ends with a word from it. Let's say the first word is 'carport'. Now, if 'car' and 'port' exist in the array...

Rewrite query string in .htaccess

I'm trying to do a very simple rewrite of a query string and I'm having no luck at all. I need to go from http:// example dot com/?ACT=jquery to http:// example dot com/index.php?ACT=jquery This is the code that I've written in my .htaccess file and it throws me an internal server error. I'm really new at this whole mod rewrite b...

Javascript code, unterminated string literal with included javascript

This script works fine, unless the included file contains javascript, then it breaks with the "unterminated string" literal error. Removing spaces and linebreaks does not cure the problem. <script type="text/javascript"> var myArray = [ 'url', 'url2', 'url3', 'url4', 'url5', ]; var i, numDomains = myArray.length, found = false; for (i =...

Removing punctuation from string in Perl

How do I remove all punctuation except for spaces from a string in Perl? ...

PHP problem, I'm sure this has an easy solution, just can't see it

Hi all, I am new to php and this little bugger has been eating up my day, perhaps it's due to some property of php I am unaware of? As part of some code for getting some data out of an xml file (using the event based Expat parser), I have the following code $xmlFields; $fieldName = ""; ............... some other code ............ fu...

format xml string

What is the best way to format XML within a PHP class. $xml = "<element attribute=\"something\">...</element>"; $xml = '<element attribute="something">...</element>'; $xml = '<element attribute=\'something\'>...</element>'; $xml = <<<EOF <element attribute="something"> </element> EOF; I'm pretty sure it is the last one! ...

Tagging similar sentences with lower time complexity than n^2

Hey All This is my first post, have been a lurker for a long time, so will try my best to explain myself here. I have been using lowest common substring method along with basic word match and substring match(regexp) for clustering similar stories on the net. But the problem is its time complexity is n^2 (I compare each title to all the...

Combining vectors of string's

Hi, I have a number of vectors of strings each containing dates. As a simple example vector A of size 2 might contain: A[0] = "01-Jul-2010"; A[1] = "03-Jul-2010"; while a second vector B of size 3 might contain: B[0] = "02-Jul-2010"; B[1] = "03-Jul-2010"; B[2] = "04-Jul-2010"; I'd like to form a vector C which contains the ...

redefine length.character in R

Since length is a generic method, why can't I do length.character <- nchar ? It seems that strings are treated special in R. Is there a reason for that? Would you discourage defining functions like head.character and tail.character? ...

How do I create a string with Quotes in it in C#

Hello, C# newbie here. I am trying to set a C# variable as follows. string profileArg = @"/profile ""eScore"" "; The end result is that I want the variable to contain the value /profile "eScore" There should be a space in the string after the "eScore" How do I do it? Seth ...

python: cleaning up a string

i have a string like this somestring='in this/ string / i have many. interesting.occurrences of {different chars} that need to .be removed ' here is the result i want: somestring='in this string i have many interesting occurrences of different chars that need to be removed' i started to manually do all kinds of .replace, but t...

How to select/remove elements from a Dictionary<string, List<string>> based on some criteria

I am trying to remove elements from a Dictionary<string, List<string>> in C# when the count of the list<string> is lesser than or equal to 1. I got some code working but it is not elegant and I have a gut feeling that this can be done elegantly in linq. This is the code I have now Dictionary<string,List<string>> FindAnagrams(...

CamelCase conversion to friendly name, i.e. Enum constants; Problems?

In my answer to this question, I mentioned that we used UpperCamelCase parsing to get a description of an enum constant not decorated with a Description attribute, but it was naive, and it didn't work in all cases. I revisited it, and this is what I came up with: var result = Regex.Replace(camelCasedString, ...

Restrict Text Box to only accept 10 digit number C++/CLI

I have a Text Box that is a System::String^, I need to confirm that this only accepts 10 digits numbers and no letters, symbols, etc. How would I implement this in C++ visual studio? Do I need to convert the contents to a std::string first? ...

Display XML in Java

I receive information from a web page as a string of xml, now I want to display that string as I would see it in a web page i.e. properly formatted. I have tried to do this with JEditorPane, but that only displays html. I know this must be possible, since I can display a web page via a link to it. ...