Is there an easy way to convert a string that contains this:
Date: Wed, 5 Nov 2008 13:12:12 -0500 (EST)
into a string that contains this:
20081105_131212
UPDATE:
I ended up using date.tryparse which is similar to tryParseExact except you don't have to specify the format string. I did have to eliminate the () and the EST for this t...
Given a UTC time string like this:
2005-11-01T00:00:00-04:00
What is the best way to convert it to a DateTime using a Crystal Reports formula?
My best solution is posted below.
I hope someone out there can blow me away with a one-liner...
...
Given the string "ThisStringHasNoSpacesButItDoesHaveCapitals" what is the best way to add spaces before the capital letters. So the end string would be "This String Has No Spaces But It Does Have Capitals"
Here is my attempt with a RegEx
System.Text.RegularExpressions.Regex.Replace(value, "[A-Z]", " $0")
...
I have the string
a.b.c.d
I want to count the occurrences of '.' in an idiomatic way, preferably a one-liner.
(Previously I had expressed this constraint as "without a loop", in case you're wondering why everyone's trying to answer without using a loop).
...
From my experiments, it does not appear to do so. If this is indeed true, what is the best method for removing line breaks? I'm currently experimenting with the parameters that TRIM accepts of the character to remove, starting with trimming \n and \r.
...
Given a word, I've to replace some specific alphabets with some specific letters such as 1 for a, 5 for b etc. I'm using regex for this. I understand that StringBuilder is the best way to deal with this problem as I'm doing a lot of string manipulations. Here is what I'm doing:
String word = "foobooandfoo";
String converted = "";
conver...
I am wondering what is the "best practice" to break long strings in C# source code. Is this string
"string1"+
"string2"+
"string3"
concatenated during compiling or in run time?
...
For a poor man's implementation of near-collation-correct sorting on the client side I need a JavaScript function that does efficient single character replacement in a string.
Here is what I mean (note that this applies to German text, other languages sort differently):
native sorting gets it wrong: a b c o u z ä ö ü
collation-correct...
I have a string that I would like to tokenize.
But the strtok() function requires my string to be a char*.
How can I do this quickly?
token = strtok(str.c_str(), " "); fails because it turns it into a const char*, not a char*
...
I would like to take a pascal-cased string like "CountOfWidgets" and convert it into something more user-friendly like "Count of Widgets" in C#. Multiple adjacent uppercase characters should be left intact. What is the most efficient way to do this?
NOTE: Duplicate of http://stackoverflow.com/questions/155303/net-how-can-you-split-a-cap...
Just that... I get a string which contains a path to a file plus some arguments. How can I recognize the path? I thought about the index of the '.' in the file... but I don't like it.
What about using regular expressions? Can anyone point me in the right direction?
Regards
Edit: Theses are valid entries...
somefile.msi /a
C:\MyFolder\S...
Hi,
i need a Regular Expression to convert a a string to a link.i wrote something but it doesnt work in asp.net.i couldnt solve and i am new in Regular Expression.This function converts (bkz: string) to (bkz: show.aspx?td=string)
Dim pattern As String = "<bkz[a-z0-9$-$&-&.-.ö-öı-ış-şç-çğ-ğü-ü\s]+)>"
Dim regex As New Regex(pattern...
In Perl
print "a" x 3; # aaa
In C#
Console.WriteLine( ??? )
...
I'd like to group the digits in a double by thousands, but also output however number of decimals are actually in the number. I cannot figure out the format string.
1000 => 1,000
100000 => 100,000
123.456 => 123.456
100000.21 => 100,000.21
100200.123456 => 100,200.123456
Disclaimers (it's not as straightforward as you think):
...
I've got a small piece of code that is parsing an index value to determine a cell input into Excel. It's got me thinking...
What's the difference between
xlsSheet.Write("C" + rowIndex.ToString(), null, title);
and
xlsSheet.Write(string.Format("C{0}", rowIndex), null, title);
Is one "better" than the other? And why?
...
Say I have a string of 16 numeric characters (i.e. 0123456789012345) what is the most efficient way to delimit it into sets like : 0123-4567-8901-2345, in PHP?
Note: I am rewriting an existing system that is painfully slow.
...
I am working on a tool where I need to convert string values to their proper object types. E.g. convert a string like 2008-11-20T16:33:21Z to a DateTime value. Numeric values like 42 and 42.42 must be converted to an Int32 value and a Double value respectively.
What is the best and most efficient approach to detect if a string is an In...
I am looking for a way to pull the first 100 characters from a string variable to put in another variable for printing.
Is there a function that can do this easily?
For example:
$string1 = "I am looking for a way to pull the first 100 characters from a string variable to put in another variable for printing.";
$string2 = 100charfunc...
Lets say you have a:
List<string> los = new List<string>();
In this crazy functional world we live in these days which one of these would be best for creating one string by concatenating these:
String.Join(String.Empty, los.ToArray());
StringBuilder builder = new StringBuilder();
los.ForEach(s => builder.Append(s));
string disp = l...
I have an app that needs to handle very large strings between a SQL Server database and .NET code. I have a LINQ query that generates the strings when saving them to the database, but when trying to create the strings from the database, the app crashes with an OutOfMemoryException because of the size of the strings.
Do I have to do some...