string

PHP String in Array Only Returns First Character

Hi Everyone, For the next week, I'm stuck with a sadly very slow 1-bar EDGE internet connection, so forgive me if I didn't spend quite enough time researching this one, but I just set up a local server for testing code that I would normally test over the internet, and it doesn't seem to be working the same way on my local LAMP install. ...

Objective-C Check for Unallowed Characters in String

Hello, How would I, in objective-c, make it so only strings with a-z characters were allowed? I.E. no & characters, no - characters, etc. Thanks! Christian Stewart ...

Prepping comma delimited string for mysql's WHERE IN

I have the following string... 1,2,3,4,5,6 I want to have this like '1','2','3','4','5','6' To use in MySQL's WHERE IN () Would anyone know the best way to do this? Thanks! ...

C# 4.0 - How to Handle Optional String Parameters

This code is not valid: private void Foo(string optionalString = string.Empty) { // do foo. } But this code is: private void Foo(string optionalString = "") { // do foo. } Why? Because string.Empty is a readonly field, not a constant, and defaults for optional parameters must be a compile-time constant. So, onto my question....

Python how to format currency string.

Hi! I have three floats that I want to output as a 2 decimal places string. amount1 = 0.1 amount2 = 0.0 amount3 = 1.87 I want to output all of them as a string that looks like 0.10, 0.00, and 1.87 respectively. How do I do that efficiently? ...

Converting an integer into English Words using C#.Net

hi.. can anybody help me to debug this... i have the following errors when executing the bolow code.. Error 1 Cannot implicitly convert type 'string' to 'long' Error 2 The name 'inputNum' does not exist in the current contex protected void Button1_Click(object sender, EventArgs e) { var englishTranslation = IntegerT...

jQuery/JavaScript: Why does this freeze?

I'm trying to implement a requirement that requires I set a maximum line length for the contents of a div element. But when I open the page in Firefox, I get an error about a "long-running script" and am asked to Continue, Debug, or Stop Script. I don't understand why this is happening. This is my code: <html> <head> <sc...

Convert expression from C# into Java

I am to convert a C# program into Java. At one point I really don't get what is done, there. I changed the code to clarify the types and give an example. string myString = "Test"; long l = (long)myString[0]; 1) What is the [0] doing with a normal string? Is that even possible? Is it just the substring, in this case "T"? 2) How could ...

Convert utf-8 std::string to std::wstring on iPhone

Hi, I have a UTF-8 string (created an std::string from a byte array) I understand that the encoding means that the size()/length() won't give me the actual number of glyphs if the text is chinese for instance... I understand that in order to get the unicode character code of each glyph I need to convert it to wstring (or any UTF>8 repres...

Double quote in C# string

Hi, I want to add double quote in c# string. string searchString = "123"; string inputString = "No matches found for "+ "\""+searchString + "\""; OutPut: No matches found for "123" THanks, ...

dump xml string verbatim to mysql db

Hi everyone, I need to dump an xml string (coming into a web service as a POST param), directly into a Mysql DB. The column into which I am writing is currently of type 'text', though I have tried blob as well. Right now, when I save the string and retrieve it later on using sql, it comes back in a serialized like format, like this: a:...

How to convert string type to user defined custom type

I have a string value that needs to be converted into my user defined custom type. how to do this, please help me. public class ItemMaster { public static ItemMaster loadFromReader(string oReader) { return oReader;//here i am unable to convert into ItemMaster type } } ...

string.Join on a List<int> or other type

I want to turn an array or list of ints into a comma delimited string, like this: string myFunction(List<int> a) { return string.Join(",", a); } But string.Join only takes List<string> as the second parameter. What is the best way to do this? ...

Java Regex Problem Replacing a String

I am getting an exception when I try to do a replaceAll: Symbols is a valid string. private String buildQuery(){ String query = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(**QUERY**)&amp;format=json&amp;env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&amp;cal...

Java regex replaceAll does not replace string

I want the text "REPLACEME" to be replaced with my StringBuffer symbols. When I print symbols, it is a valid string. When I print my query, it still has the text REPLACEME instead of symbols. Why? private String buildQuery(){ String query = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%...

How to compute shortest unique prefixes of a set of strings?

It's a pretty common algorithm in command line parsing. Given a set of predefined long option names -- compute the shortest prefix that uniquely identifies one of these options. So for instance, for the following options: -help -hostname -portnumber -name -polymorphic This would be the output: -he -ho -por -n -pol I'm thinking tw...

Static char array not found and not working with strncpy?

char * function decode time() { tm *ptm; //time structure static char timeString[STRLEN]; //hold string from asctime() ptm = gmtime( (const time_t *)&ltime ); //fill in time structure with ltime if(ptm) { strncpy(timeString, asctime( ptm ), sizeof(timeString) ); //EDIT sprintf(test, "Sting is: %s", tim...

Demonstrating string comparison with Java

I want to demonstrate with a few line of code that in Java, that to compare two strings (String), you have to use equals() instead of the operator ==. Here is something I tried : public static void main(String Args[]) { String s1 = "Hello"; String s2 = "Hello"; if (s1 == s2) System.out.println("same strings"); else ...

Make C char array from NSString object in Obj-C.

Hi, I want to make a C char array from NSString object in Obj-C. My string is: NSString *string = [[NSString alloc] initWithContentsOfURL:url usedEncoding:nil error:nil]; Can someone send me a sample of a working code? Thanks in advance, Sagiftw ...

C#/.NET: Can I get a string of valid HTML from a Stream?

Ok, so I'm rendering a partial view control in memory that generates HTML that I would like to get to a PDF renderer. The renderer only takes a string as an argument. I have a MemoryStream containing the HTML that I need to get to the renderer. This is what I'd like to do: inStream is the MemoryStream of HTML from the partial view. do...