string

Get all characters from a string with their number

How in Java can I get list of all characters appearing in string, with number of their appearances ? Let's say we have a string "I am really busy right now" so I should get : i-2, a-2, r-2, m-1 and so on. ...

Why is this c++ string concatenation missing a space?

I am working with c++ strings, and am a beginner at programming. I am expecting: 99 Red Balloons But I am receiving: 99 RedBalloons Why is that? #include <string> #include <iostream> using namespace std; int main() { string text = "9"; string term( "9 "); string info = "Toys"; string color; char hue[4] = {'R','e...

Compare versions as strings

Comparing version numbers as strings is not so easy... "1.0.0.9" > "1.0.0.10", but it's not correct. Obvious way to do it properly is parse these strings, convert to numbers and compare as numbers. Is it other way to do it more "elegant"? For example, boost::string_algo... ...

how to convert current date into string in java?

how to convert current date into string in java? ...

How can I escape '"' when reading a csv-file with JDBC?

I am reading a csv-file with JDBC, using CsvJdbc. Some strings in the csv-file contains a "-char, how can I handle these situations? When I am reading the csv-file with: while (results.next()) { String name = results.getString("Name"); ... } I get this SQLException, on the line where I have while (results.next()) { java.sql....

built in function to combine overlapping string sequences in php?

Is there a built in function in PHP that would combine 2 strings into 1? Example: $string1 = 'abcde'; $string2 = 'cdefg'; Combine to get: abcdefg. If the exact overlapping sequence and the position are known, then it is possible to write a code to merge them. TIA ...

C++: Why does space always terminate a string when read?

Using type std::string to accept a sentence, for practice (I haven't worked with strings in C++ much) I'm checking if a character is a vowel or not. I got this: for(i = 0; i <= analyse.length(); i++) { if(analyse[i] == 'a' || analyse[i] == 'e' [..etc..]) { ...vowels++; } else { ... ...consonants++; } This works fine if the strin...

How to remove characters from a string?

Hi, (my first post was not clear and confusing so I've edited the question) I was studying string manipulation. You can use strlen() or substr() but cannot rely on other functions that are predefined in libraries. Given string $string = "This is a pen", remove "is" so that return value is "Th a pen" (including 3 whitespaces). Remo...

int value under 10 Convert to string two digit number

string strI; for(int i = 1;i<100;i++) strI = i.ToString(); in here, if i is 1 then strI is '1' But I want to get '01' or '001' it looks quite easy. but there's only article about datetime.tostring("yyyy-MM-dd") :( ...

What classes do you use to make string templates?

What classes do you use to make string placeholders work? String template = "You have %1 tickets for %d", Brr object = new Brr(template, {new Integer(1), new Date()}); object.print(); ...

JQuery removing '-' character from string

Hi, I hope this question isn't too basic. I have a string "-123445". Is it possible to remove the '-' character from the string? I have tried the following but to no avail: $mylabel.text("-123456"); $mylabel.text().replace('-', ''); Any help would be greatly appreciated. Thanks, Zaps ...

Byte from string/int in C++

Hi, I'm a beginning user in C++ and I want to know how to do this: How can I 'create' a byte from a string/int. So for example I've: string some_byte = "202"; When I would save that byte to a file, I want that the file is 1 byte instead of 3 bytes. How is that possible? Thanks in advance, Tim ...

Comparing strings that contain formatting in C#

I'm working on a function that given some settings - such as line spacing, the output (in string form) is modified. In order to test such scenarios, I'm using string literals, as shown below for the expected result. The method, using a string builder, (AppendLine) generates the said output. One issue I have run into is that of comparing...

Why does this crash: stringByAppendingFormat

Hey. My code crashes at this function (at the stringByAppendingFormat: with error objc_msgSend() selector name: stringByAppendingFormat). This is that line: // imagesPath = ...iPhone Simulator/4.0/Applications/NUMBERS/Documents/images UIImage *image = [[UIImage alloc] initWithContentsOfFile:[imagesPath stringByAppendingFormat:@"/%...

How can I truncate an NSString to a set length?

I searched, but surprisingly couldn't find an answer. I have a long NSString that I want to shorten. I want the maximum length to be around 20 characters. I read somewhere that the best solution is to use substringWithRange. Is this the best way to truncate a string? NSRange stringRange = {0,20}; NSString *myString = @"This is a strin...

in javascript, best way to Remove Non Numeric characters from the Beginning of a String?

-_1234d5fr should ideally turn into 1234d5fr Thank you so much! ...

declare or convert a string to array format PHP

How to convert a string format into an array format? I have a string, $string = 'abcde' I want to convert it to a 1 element array $string[0] = 'abcde' Is there a built in function for this task? Or the shortest way is to $string = 'abcde'; $array[0] = $string; $string = $array; TIA ...

Extracting data from a non-formatted string

I want to extract certain parts and be able to put it into a nice spreadsheet format. The important parts are the address, ward number, square feet, and price. I was going to try something really complicated in PHP(novice), but thought there might be an easier way. The data looks like this: 243-467 1402 E. Mt. Pleasant Ave. 50th...

Best practice or performance difference between ToString() and & concatenation

When I am concatenating object values together to form a string in VB.NET, is there a difference in performance or a recommended best practice between using the & concat or the + concat with calls to .ToString() on each object? Example (which is faster or best practice): Dim result1 As String = 10 & "em" Dim result2 As String = 10.ToSt...

How to diagnose, and reverse (not prevent) Unicode mangling

Somewhere upstream of me, "something" happened that looks like unicode mangling. One symptom is that a lowercase u umlaut (ü) gets converted to "ü" (ie, character FC gets converted to C3 BC). Assuming that I have no control over this upstream process, how can I reverse-engineer what's going on? And if that is possible, can I crank the s...