string

Read multiple lines from InputStreamReader (JAVA)

I have an InputStreamReader object. I want to read multiple lines into a buffer/array using one function call (without crating a mass of string objects). Is there a simple way to do so? ...

Ruby concatenate strings and add spaces

I have 4 string variables name, quest, favorite_color, speed that might be empty. I want to concatenate them all together, putting spaces between those that aren't empty. So: name = 'Tim' quest = 'destroy' favorite_color = 'red' speed = 'fast' becomes 'Tim destroy red fast' and name = 'Steve' quest = '' favorite_color = '' speed...

how to place - in a string.

I have a string "8329874566". I want to place - in the string like this "832-98-4566" Which string function can I use? ...

Calculation Expression Parser with Nesting and Variables in ActionScript

Hi There, I'm trying to enable dynamic fields in the configuration file for my mapping app, but I can't figure out how to parse the "equation" passed in by the user, at least not without writing a whole parser from scratch! I'm sure there is some easier way to do this, and so I'm asking for ideas! Basic idea: public var testString:Stri...

Why are string and vector distinct types?

They're both resizable arrays, and std::basic_string doesn't have any specifically character-related functions like upper(). What's special about string to make it better for character data? ...

Simple regex question?

In the streams I am parsing I need to parse something in this pattern: <b>PaintTitle</b></td><td class=detail valign="top" align=left><div align=left><font size=small><b>The new great album by Pet Shop Boys</b> How would I get the string "The new great album by Pet Shop Boys" where <b>PaintTitle</b> is guaranteed to be once per album?...

PHP: Format a numeric string by inserting comma

I need a way to convert a number into formatted way by inserting comma at suitable places. Can it be done using regex? Example: 12345 => 12,345 1234567 =>1,234,567 ...

Capitalize Words in PHP with custom delimitor

Hey guys, i need a method to capitalize every first letter of a word. This is what i got so far and it is working for almost every string...but it fails on this one "WELLNESS & RENOMME". // method in stringModify Class function capitalizeWords($words, $charList) { $capitalizeNext = true; for ($i = 0, $max = strlen($wo...

How to store dynamic references to parts of a text

In fact, my question concerns an algorithm. I need to be able to attach annotations to certain parts of a text, like a word or a group of words. The first thing that came to me to do so is to store the position of this part (indexes) in the text. For instance, in the text 'The quick brown fox jumps over the lazy dog', I'd like to attach...

Java, HashMaps and using Strings as the keys - does the string value get stored twice?

If I have a HashMap that looks like this: HashMap<String, MyObject> where the String key is a field in MyObject, does this string value get stored twice? So when I add entries: _myMap.put(myObj.getName(), myObj); Am I using double the String size in terms of memory? Or does Java do something clever behind the scenes? Thanks ...

What's a great way to convert a string to a number in C#?

I'm familiar with: Convert.ToInt32(texthere); But is there another cleaner way to do it? I like having readable code for coworkers and I'm always on the lookout for anything that'll make my work seem more obvious. ...

Use stringWithFormat: as a file path in cocoa

Hello, I'm having a problem with a cocoa application that takes the value of a text field, and writes it to a file. The file path is made using stringWithFormat: to combine 2 strings. For some reason it will not create the file and the console says nothing. Here is my code: //Get the values of the text field NSString *fileName = [fileN...

C# adding string elements of 4 different string arrays with each other

Hello. I need an advice about how to create new string array from 4 different string arrays: We have 4 string arrays: string[] arr1 = new string [] {"a1","a2","a3"..., "a30"}; string[] arr2 = new string [] {"d10","d11","d12","d13","d14","d15"}; string[] arr3 = new string [] {"f1","f2","f3"...,"f20"}; string[] arr4 = new stri...

Input string was not in a correct format. Converting String to double .

I'm quite a beginner in C# , empty string to double conversion can be carried out under the button1_click event ..but doing it under Public Form1() it gives me this error Input string was not in a correct format. Here`s the code..(the form1.cs and the Guy.cs class) using System; using System.Collections.Generic; using Syste...

How to pass a very long string/file into RESTWebservice JAX-RS Jersey

Hello All, I wrote a RESTful webservice using JAX-RS API, that returns an XML string. I am trying to write another RESTful webservice that takes in this XML string, does parsing of it using DOM and extract particular things I want. The XML string happens to be very long so I do not want to pass it as a @QueryParam or @PathParam. Say I...

Reverse "Hello World" in Java

Hello I want to do reverse each word of the String in Java example if input String is "Hello World" then the output should be "olleH dlroW". ...

Inserting "£" in a string to a text file

iPhone Application writes data to a text file, saves it on the Documnets folder. Great that works If I place "£" in the string, or use [currencyStyle stringFromNumber] the text file will not be created. The "£" and the [currencyStyle stringFromNumber] works if the information is printed to a "New View" page on the simulator, pound and...

Write Secure Cocoa Code

Hello, Im making an application in cocoa and wanted to see if some strings in it were easily accessible so I ran OTX on it and sadly all of my code was found. Is there a method I can use to make my code more "secure" or at least encrypt/hide the strings? The reason I want to encrypt the string is it's a password for a server. I don'd ne...

std::string constructor corrupts pointer

I have an Entity class, which contains 3 pointers: m_rigidBody, m_entity, and m_parent. Somewhere in Entity::setModel(std::string model), it's crashing. Apparently, this is caused by bad data in m_entity. The weird thing is that I nulled it in the constructor and haven't touched it since then. I debugged it and put a watchpoint on it, an...

String that contains all ascii characters

Hi, I want to create a string in JavaScript that contains all ascii characters. How can I do this? ...