string

Generate list of all possible permutations of a string

How would I go about generating a list of all possible permutations of a string between x and y characters in length, containing a variable list of characters. Any language would work but it should be portable....

Format string to title case

How do I format a string to title case?...

What is the best way to parse strings in Java

I have some friends making a text-based game in Java (what the hell?), and they're looking for the best way to parse strings for commands. They've come across many methods and are wondering what would be the best way to go about things....

String.indexOf function in C

Is there a C library function that will return the index of a character in a string? So far, all I've found are functions like strstr that will return the found char *, not it's location in the original string....

In C# what is the difference between String and string

In C# what is the difference between String and string? (note the case) Also, what are the guidelines for the use of each? ...

Test serialization encoding

What is the best way to verify/test that a text string is serialized to a byte array with a certain encoding? In my case, I want to verify that an XML structure is serialized to a byte array with the UTF-8 encoding which is of variable character length. As an example, my current ugly procedure is to inject a character known to require t...

Remove Quotes and Commas from a String in MySQL

I'm importing some data from a CSV file, and numbers that are larger 1000 get turned into "1,100" etc. What's a good way to remove both the quotes and the comma from this so I can put it into an int field? Edit: The data is actually already in a MySQL table, so I need to be able to this using SQL. Sorry for the mixup. ...

Checking for string contents? string Length Vs Empty String

Which is more efficient for the compiler and the best practice for checking whether a string is blank? Checking whether the length of the string == 0 Checking whether the string is empty (strVar == "") Also, does the answer depend on language? ...

Why doesn't Ruby have a real StringBuffer or StringIO?

I recently read a nice post on using StringIO in Ruby. What the author doesn't mention, though, is that StringIO is just an "I." There's no "O." You can't do this, for example: s = StringIO.new s << 'foo' s << 'bar' s.to_s # => should be "foo\nbar" # => really is ''` Ruby really needs a StringBuffer just like the one Java has. Stri...

Case insensitive string comparison in C++

What is the best way of doing case insensitive string comparison in C++ with out transforming a string to all upper or lower case? Also, what ever methods you present, are they Unicode friendly? Are they portable? ...

PowerShell - how do I do a string replacement in a function?

How do I convert function input parameters to the right type? I want to return a string that has part of the URL passed into it removed. This works but uses a hard coded string: function CleanUrl($input) { $x = "http://google.com".Replace("http://", "") return $x } $SiteName = CleanUrl($HostHeader) echo $SiteName This fails:...

How do I Convert a string to an enum in C#?

What's the best way to convert a string to an enumeration value in C#? I have an HTML select tag containing the values of an enumeration. When the page is posted, I want to pick up the value (which will be in the form of a string) and convert it to the enumeration value. In an ideal world, I could do something like this: StatusEnum M...

C# Save Dialogs

What would be the easiest way to separate the directory name from the file name when dealing with SaveFileDialog.FileName in C#? ...

Parse usable Street Address, City, State, Zip from a string

Problem: I have an address field from an Access database which has been converted to Sql Server 2005. This field has everything all in one field. I need to parse out the individual sections of the address into their appropriate fields in a normalized table. I need to do this for approximately 4,000 records and it needs to be repeatable. ...

C# String output: format or concat?

Let's say that you want to output or concat strings, what style do you prefer: var p = new { FirstName = "Bill", LastName = "Gates" }; Console.WriteLine("{0} {1}", p.FirstName, p.LastName); Console.WriteLine(p.FirstName + " " + p.LastName); Do you rather use format or do you simply concat strings? What is you...

Java: Best way of converting List<Integer> to List<String>

I have a Java list of integers, List<Integer> and I'd like to convert all the integer objects into strings, thus finishing up with a new List<String>. Naturally, I could create a new List and loop through and String.valueOf() all the integers, but I was wondering if there was a better (read: more automatic) way of doing it? [Minor edit...

What's the best string concatenation method using C#?

What's the most efficient way to concatenate strings? ...

PowerShell - How do I pass string parameters correctly?

Is there documentation or an article on the rules for passing strings into PowerShell functions? I just trying to do some string concatenation/formatting, but it's putting all the parameters into the first placeholder. Code function CreateAppPoolScript([string]$AppPoolName, [string]$AppPoolUser, [string]$AppPoolPass) { # Command to...

Why is String.Format static?

Compare String.Format("Hello {0}", "World"); with "Hello {0}".Format("World"); Why did the .Net designers choose a static method over an instance method? What do you think? ...

What would be the fastest way to remove Newlines from a String in C#?

Hi community, I have a string that has some Environment.Newline in it. I'd like to strip those from the string and instead, replace the Newline with something like a comma. What would be, in your opinion, the best way to do this using C#.NET 2.0? Thanks in advance. ...