string

.net Format decimal to two places or a whole number

For 10 I want 10 and not 10.00 For 10.11 I want 10.11 Is this possible without code? i.e. by specifying a format string alone simlar to {0:N2} Thanks! ...

How to deal with big strings and limited memory

I have a file from which I read data. All the text from this file is stored in a String variable (a very big variable). Then in another part of my app I want to walk through this string and extract useful information, step-by-step (parsing the string). In the meanwhile my memory gets full and an OutOfMemory exception keeps me from furth...

Segmentation fault depending on string length?

I am writing a program that will read lines from an infile using getline into strings, convert the strings to c-strings containing the first m nonwhitespace characters of the string, then concatenate the c-strings into a single char array. A sample file might look something like this: 5 //number of rows and columns in a grid 2 //...

Java swing: Multiline labels?

Hi, I want to do this: JLabel myLabel = new JLabel(); myLabel.setText("This is\na multi-line string"); Currently this results in a label that displays This isa multi-line string I want it to do this instead: This is a multi-line string Any suggestions? Thank you EDIT: Implemented solution In body of method: myLabel.setTex...

Mysql compare Strings

Hi, from a resultset of about 5 different strings, I would like to select the result of which the string resembles my given string the most. Is there any possibility to do this in mysql? ...

In VB.NET create a string from parts of a different string

This string is automatically generated with an application I can't access or change: "http://www.site.com/locale=euen&mag=testit&issue=322&page=5&template=testit-t1" I need to change the string to "http://www.site.com/322_5" where: http://www.site.com/ comes from the previous string 322 comes from issue=322 5 comes f...

Markov C++ read from file perfomance

Hi all, I have my 2nd assignment for C++ class which includes Markov chains, The assignment is simple but I'm not able to figure out what is the best implementation when reading chars from files I have a file around 300k, one of the rules for the assignment is to use Map and Vector classes in Map (key is only string) and values will be ...

Javascript Large String storing in code vs. storing in a dom object (such as a <pre> , <div>)

I have a large javascript string. var s = '...............'; // this is about 32000 characters long. if you wonder: that bit of javascript is autogenerated. Does anybody know if it is better to store it outside of the javascript For instance in a dom object in the html page and then retrieve it (e.g. var s = document.getElementById(...

Method return type String is not a String

First of all, my target here is to read from a URL, parse it, and take information from it and give it to another method sendMessage which then sends it to an IRC client. I haven't been doing java long so I'm adapting things I code I find on the internet. The below methods work when they are declared in their own class file, and run by p...

String has how many parameters

Before using String.Format to format a string in C#, I would like to know how many parameters does that string accept? For eg. if the string was "{0} is not the same as {1}", I would like to know that this string accepts two parameters For eg. if the string was "{0} is not the same as {1} and {2}", the string accepts 3 parameters How...

String Split & Search VB.NET

Need to take a string in vb and split it. Also need to look through the two returned values and return the value which contains "domain1.com". Pipelines are the delimiter. txtEmailFrom.Text = "[email protected]|[email protected]" Dim brokened() As String brokened = Split(txtEmailFrom.Text, "|") Dont know where to go from here... ...

Non-Deprecated StringBufferInputStream equivalent

I'm working with LogManager.readConfiguration() which requires an InputStream whose contents I'd like to come from a string. Is there an equivalent of StringBufferInputStream that's not deprecated, such as a ReaderToInputStreamAdaptor? ...

Calling Echo inside a function pre-pends echo string to return value in Powershell

Hey guys, I'm a Powershell noob and seem to keep getting caught on little weird behaviors like this. Here is some test code: function EchoReturnTest(){ echo "afdsfadsf" return "blah" } $variable = EchoReturnTest echo ("var: " + $variable) Running this script generates this as output: "var: afdsfadsf blah" Why does the...

grouping strings by similarity

I have an array of strings, not many (maybe a few hundreds) but often long (a few hundred chars). Those string are, generally, nonsense and different one from the other.. but in a group of those string, maybe 5 out of 300, there's a great similarity. In fact they are the same string, what differs is formatting, punctuation and a few wor...

Split string into array of chars in C++

Hello, I'm writing a program that requires a string to be inputed, then broken up into individual letters. Essentially, I need help finding a way to turn "string" into ["s","t","r","i","n","g"]. The strings are also stored using the string data type instead of just an array of chars be default. I would like to keep it that way and avoid ...

Regex : how to get words from a string (C#)

My input consists of user-posted strings. What I want to do is create a dictionary with words, and how often they've been used. This means I want to parse a string, remove all garbage, and get a list of words as output. For example, say the input is : "#@!@LOLOLOL YOU'VE BEEN *PWN3D* ! :') !!!1einszwei drei !" The output I need is the...

string replace in a large file with php

I am trying to do a string replace for entire file in PHP. My file is over 100MB so I have to go line by line and can not use file_get_contents(). Is there a good solution to this? ...

Parsing of string for SQL DataType

I'm doing some reflection on generated LINQ to SQL classes (i.e. DataContext). For each property (column) on a class (table) I'm getting the ColumnAttribute.DbType value. It can be various different values, here's some examples: Int NOT NULL Int VarChar(255) VarChar(255) NOT NULL Bit ... and so on. If I wanted to parse these strin...

How can using strings instead of simple types like integers alter the O-notation of operations?

Proposed answer: Strings are simply arrays of characters so the O-notation will be dependent on the number of characters in the string (if the loop depends on the length of the string). In this case the O-notation wouldn't be affected because the length of the string is a constant. Any other ideas? Am I reading this question corre...

Find common chars in array of strings, in the right order.

Hello, I spent days working on a function to get common chars in an array of strings, in the right order, to create a wildcard. Here is an example to explain my problem. I made about 3 functions, but I always have a bug when the absolute position of each letter is different. Let's assume "+" is the "wildcard char": Array( 0 => '48ca1...