string

PHP string cut short

Why does this code $string = "!@#$%^&*(<[email protected]"; echo $string; only output: !@#$%^&*( Is this is a PHP bug? ...

C# - Given a string that is representing a numeric percentage, a way to extract the whole percentage?

Possible Duplicate: How do I convert the string 39.9983% into 39% in C#? I have a "String" that is "39.999%", I'd like to extract "39" and % out of it. Similarly, a 0.9% would yield 0% ...

What's in the memory of a dynamic array when used with SetLength in Delphi?

I have a dynamic array myArr. What is stored in the memory in myArr when we use SetLength on it? Is it '00'? Or undefined? SetLength allocates 16 bytes of memory for myArr in this case. myArr : array of byte; SetLength(myArr, 16); ...

Is category nesting as a "string chain" a bad idea?

Thinking of building a nested category "system" using "chained strings" for lack of a better term. Here's the plan: A category slug could be something like "shopping-clothing-womans". This would correlate to a 3 deep category: Shopping > Clothing > Woman's. An object in the database would have a category field, containing the slug. Let...

Checking if 2 strings contain the same characters?

Is there a way to check if two strings contain the same characters. For example, abc, bca -> true aaa, aaa -> true aab, bba -> false abc, def -> false ...

Sending C strings and vectors to MurmurHash gives inconsistent results.

I'm trying to use MurmurHash (returning 64 bit hashes on a 64bit comoputer) and have sent it the simple 3 letter string 'yes' as follows char* charptr = "yes"; cout << MurmurHash64A(charptr, 3, 10); (where 3 is the length and 10 is the seed) This gives a 64bit hashed response as expected, I can set up more pointers to C strings holdin...

how to remove new lines and returns from php string?

A php variable contains the following string: <p>text</p> <p>text2</p> <ul> <li>item1</li> <li>item2</li> </ul> I want to remove all the new line characters in this string so the string will look like this: <p>text</p><p>text2><ul><li>item1</li><li>item2</li></ul> I've tried the following without success: str_replace('\n', '', $st...

Get string value in Android

There are some string resources in my android application and some helper-classes, which are only java-classes (no android classes). Is it possible to get string value of string resource variable from an java class?! Mur ...

RoR: Creating an Object with string primary_key (associated error: Couldn't find Object_Id with ID=0)

I created a model that had a string primary_key. The Create action in Ruby on Rails gave me the following error: Couldn't find Theme with ID=0 My Theme table has no ID column, but a string column called name which is the primary key. After searching everywhere, I experimented myself with the Create action inside the theme_controller....

Searching for multiple strings in multiple files

I have a text file containing 21000 strings (one line each) and 500 MB of other text files (maily source codes). For each string I need to determine if it is contained in any of those files. I wrote program that does the job but its performance is terrible (it would do that in couple of days, I need to have the job done in 5-6 hours max)...

How to do ToString for a possibly null object?

Is there a simple way of doing the following: String s = myObj == null ? "" : myObj.ToString(); I know I can do the following, but I really consider it as a hack: String s = "" + myObj; It would be great if Convert.ToString() had a proper overload for this. ...

Linked Lists, Assigning char array [C]

Hi all. I've got the task of making a car rental program, which uses linked lists to control what cars are available for rent, are rented, or are in repair. The 'car' is a structure, and so is the rented list, available list, and repair list. Heres my current issue. If the user wants to make a new car available, we must add it to our l...

bash: extract double from string

hello I have this string in bash: str=sdk.iphoneos4.1.sdk and I would like to have a variable with '4.1' in it is there any way to parse a float/double value in bash ? ...

converting a String to UTF8 format

Hi, I java code, i am having a string name = "örebro"; // its a swedish character. But when i use this name in web application. i prints some specail character at 'Ö' character. Is there anyway i can use the same character as it is in "örebro". i did some thing like this but does not worked. String name = "örebro"; byte[] utf8s ...

Char* vs String Speed in C++

I have a C++ program that will read in data from a binary file and originally I stored data in std::vector<char*> data. I have changed my code so that I am now using strings instead of char*, so that std::vector<std::string> data. Some changes I had to make was to change from strcmp to compare for example. However I have seen my execut...

Parameter length too long

I have a java program, and I need to pass to its main method a parameter that has a length of 8k characters. So when I try to execute this program passing that parameter, It just doesn't execute, but no error message is shown. How can I execute correctly that program? ...

Could you share a link to an URL parsing implementation?

...

get string after and before word

i need to get a set of values after certain 14 length of a string and before the last 5 stringss. eg: Theboyisgoingt9123holdi: so i need to get the value 9123 iamfullofmeats89holdi: i need to extract value 89 so the algorithm here is, i am trying to extract the values that comes after the 14th length of the string and just before the ...

correct idiom for character string (not std::string) constants in c++

A while ago I asked about std::string constants http://stackoverflow.com/questions/2312860/correct-idiom-for-stdstring-constants. What I took away from that was not to use std::string constants but to use char string constants. So what the best idiom for that #define FOO "foo" const char * const FOO = "foo"; const char FOO[] = "foo";...

Bottleneck from comparing strings

This is a follow up question to Char* vs String Speed in C++. I have declared the following variables: std::vector<std::string> siteNames_; std::vector<unsigned int> ids_; std::vector<std::string> names_; I call this function tens of thousands of times and is a major bottleneck. Is there a more efficient way to compare strings? The a...