The title pretty much says it all. What's the simplest/most elegant way that I can convert, in Java, a string from the format "THIS_IS_AN_EXAMPLE_STRING" to the format "ThisIsAnExampleString"? I figure there must be at least one way to do it using String.replaceAll() and a regex, but I've really never understood Java regexes.
My initial ...
I have $_SERVER['HTTP_REFERER'], pretend it is http://example.com/i/like/turtles.html .
What would i need to do to get just the "http://example.com" part out of the string and set into its own variable?
...
I have a design question. I have a website where users enter short messages and they are displayed to other users. Sometimes these messages have formatting in them so I need to manipulate strings. I can do this either on the server or on the client. My question is where should it occur?
If it happens on the server then there's more of ...
"abc def"
"abcd efgh"
If I have a large string with a space that separates two substrings of varying length, what's the best way to extract each of the substrings from the larger string?
Because this is a string rather than an array, array syntax s[0] will only retrieve the first letter of the string ('a'), rather than the first subst...
I have a string: "hello good old world" and i want to upper case every first letter of every word, not the whole string with .toUpperCase(). Is there an existing java helper which does the job?
...
join_strings(string $glue, string $var, string $var2 [, string $...]);
I am looking for something that would behave similar to the function I conceptualized above. A functional example would be:
$title = "Mr.";
$fname = "Jonathan";
$lname = "Sampson";
print join_strings(" ", $title, $fname, $lname); // Mr. Jonathan Sampson
After gi...
I am writing a front-end for a command line utility in Objective-C (Cocoa). I need to parse the output to check for different types of messages. There are two basic types; information messages and download status messages. Information messages always begin with one of the following: INFO:, WARNING:, ERROR:, or : . The download status mes...
Not that I would want to use this practically (for many reasons) but out of strict curiousity I would like to know if there is a way to reverse order a string using LINQ and/or LAMBDA expressions in one line of code, without utilising any framework "Reverse" methods.
e.g.
string value = "reverse me";
string reversedValue = (....);
an...
Hello,
The strings are of the following pattern
1.0.0.0
1.0.0.1
1.0.0.2
...
...
...
I am looking for a code which will read the last created string and increment the last numeral by 1 and save it as a new string.
How do I do it?
Best Regards,
Magic
...
We have a string that has a maximum limit of 20 words. If the user enters something that is more than 20 words, we then need to truncate the string at its 20th word. How can we automate this? We are able to find the 20th token with #GetToken(myString, 20, ' ')#, but are unsure on how to find it's position in order to left-trim. Any ideas...
I'm working on some code that is normalizing a lot of data. At the end of processing, a number of key="value" pairs is written out to a file.
The "value" part could be anything, so at the point of output the values must have any embedded quotes escaped as \".
Right now, I'm using the following:
outstream << boost::regex_replace(src, ...
I have a string:
string cover = "withaname"
I would like to change the withaname to withnoname.
I would then like to change withnoname to withanamegoose.
What is the best way to accomplish this in LSL?
...
I need to build an NSString that resembles the following:
Name: Craig Buchanan
Telephone: 800-555-1212
Email: [email protected]
Where:
each line (e.g. Telephone) is included or excluded based on the value of a UISwitch
the key part of the string (i.e. the part to the left of the ':') is localized
the value part is from a UITextField...
i have a string .
i want to reverse the letters in every word not reverse the words order.
like - 'my string'
should be
'ym gnirts'
...
I have data which I wish to be pasted into a textbox, it will be in the form E.G
Ryu Aiter D78:21:87:13 177 /177 1 / 6
Ryu Chronos D78:21:26:21 182 /182 0 / 6
Ryu Hermes D78:21:26:22 201 /201 0 / 6
Ryu Hefaistos D78:31:75:10 136 /136 1 / 2
Ryu Krotos D78:84:96:11 170 /170 1 / 6
Ryu Heros D78:65:51:31 175 /175 2 / 5
Ryu Arachnos D78:13:8...
Here is another old function I have from my C# 1 days, what would be a more elegant way to write it:
//method: gets the text in a string in front of a marker, if marker is not there, then return empty string
//example: GetTextAfterMarker("documents/jan/letter043.doc","/") returns "documents"
//example: GetTextAfterMarker("letter043.doc"...
I need a way to split a UK postcode from user entry. This means the postocode could be nicely formatted full code like so "AB1 1BA" or it could be anything you could imagine. I've seen some regex to check the format of the postcode but it's knowing where to split it if I'm given something like "AB111AD" etc..
This is to return the first ...
How can I refactor this so that numberOfItems doesn't have to be declared as a variable?
//method: gets the text in a string in front of a marker, if marker is not there, then return empty string
//example: GetTextAfterMarker("documents/jan/letter043.doc","/") returns "letter043.doc"
//example: GetTextAfterMarker("letter043.doc","/") re...
I am working on some rather inefficient C# code that wants to remove blanks lines. It does this:
string b;
...
while ( b.IndexOf("\n\n") >= 0 )
b = b.Replace ("\n\n", "\n");
A single replace would not cope with (e.g.) \n\n\n in the input, so the loop is needed. I think it ought to work, and it usually does.
But...
Is there a simple way of taking the value of a property and then copy it to another property with certain characters replaced?
Say propA=This is a value. I want to replace all the spaces in it into underscores, resulting in propB=This_is_a_value.
...