string

Converting string to float throws error "Incorrect format"

I can't get my application to convert a string into a float: float number = float.Parse(match); Where match is "0.791794". Why doesn't this work? The error I get is "Input string was not in a correct format.", but I can't understand what's wrong with it. ...

Creating a 2D String Array from a ArrayList

I have a array list of objects (<ArrayList> Cars) which contains two single elements. These elements are New Car Model[name=Prius, manufacturer=Toyota, year=2001] and New Car Model[name=Panda, manufacturer=Fiat, year=2005;]. I would like to create a two dimensional String array (in this case String [2][3] Cars] where to each car would co...

Covert String to LPVOID and LPCWSTR in C++

Hi, I’m working with the winHTTP API in c++ and I have started to write a wrapper class for my application. For simplicity I have a number of functions that can take string parameters and use them in the winHTTP calls. However many of these require the data to be LPVOID or LPCWSTR. I can make it all work by making my wrapper functions ...

Why is it called a 'String'?

Possible Duplicate: The History Behind the Definition of a String In most programming languages a string is a sequence of characters. Why is it named that? The earliest instance of it being called a string is Algol 60 (as far as I know). Question posed by Douglas Crockford in his talk today (will post when talk is online). ...

Why does Perl replace my string with "1"?

I have the following code: #$domain = domainname.co.uk #$root = public_html #$webpage = domainname.co.uk/foo/bar/foobar.html my $string = ($webpage =~ s/^$domain//g); my $linkFromRoot = $dbh->quote($root . $string); Usualy this works fine but for some reason the output is "public_html 1" instead of "public_html/foo/bar/foobar.html". ...

Simple but confusing Ruby string manipulation.

I am trying to convert a small bit of Ruby to PHP, and I have had success so far, except for this one line: string = string[16,string.length-16] I have tried these two things in PHP: $string = substr($string, 16, strlen($string) - 16); // and $string = substr($string, 16, strlen($string) - 32); But the problem is that I have no clu...

How to write a full string to a file?

Hi, I'm programming in Windows right now, but portable code would be welcomed too. What I'm using right now is fwrite(4), but this function needs a maximum number of elements to be written to the file. I can use strlen(1) here but I'd like to know if there is any better way to do this. ...

Get text after needle?

If i had the following text in a string: <h4>Tom</h4> <p>One Paragraph</p> <p>Two Paragraph</p> What code would i need to parse on that string to get an output like this (if i didnt know what was inside the <h4> tag? <p>One Paragraph</p> <p>two Paragraph</p> Thanks! ...

How to convert array to string and vice versa?

How to convert a array <-> string? I've a bi dimensional array and i need to save to database and retrieve. Dim myarray(,) as string = {{"some","some"},{"some","some"}} ...

ANSI C: How to split a string by newline and get a random line

Hi, I'm a new to C and got stuck with subj. I can split string with strtok but I don't know how to get a random token. Thanks. ...

Ruby Gsub! question

params[:hello] # => "Some params value" hello = params[:hello] hello.gsub!("whatever","") params[:hello] # => "" I don't understand, can someone please explain why the params[:hello] gets modified by the gsub! ? I expected the hello string to be modified, but not the params hash. ...

concatenate char array in C

I have a a char array: char* name = "hello"; I want to add an extension to that name to make it hello.txt How can I do this? name += ".txt" won't work ...

Unusual Font Conversion

Hi All, I have the following string in a file, and it needs to be converted back to a Font object. But I'm not sure how to do this one: font string: [Font: Name=Segoe UI, Size=14, Units=3, GdiCharSet=1, GdiVerticalFont=False] I appreciate any help at all, thank you bael ...

How many bytes in a JavaScript string?

I have a javascript string which is about 500K when being sent from the server in UTF-8. How can I tell its size in JavaScript? I know that JavaScript uses UCS-2, so does that mean 2 bytes per character. However, does it depend on the JavaScript implementation? Or on the page encoding or maybe content-type? ...

Regular expression to find two strings anywhere in input

How do I write a regular expression to match two given strings, at any position in the string? For example, if I am searching for cat and mat, it should match: The cat slept on the mat in front of the fire. At 5:00 pm, I found the cat scratching the wool off the mat. etc. No matter what precedes these strings. ...

PHP functions wont work with String object, but works with it typed manually

Hi, I'm trying to strip tags from a text output coming from an object. The problem is, that I can't. If I type it manually like "<p>http://www.mylink.com&lt;/p&gt;", it works fine! When doing echo $item->text; it gives me the same string "<p>http://www.mylink.com&lt;/p&gt;"; Doing var_dump or even gettype, gives me a string(). So, I'm s...

Why do strings in C need to be null terminated?

Just wondering why this is the case. I'm eager to know more about low level languages, and I'm only into the basics of C and this is already confusing me. Do languages like PHP automatically null terminate strings as they are being interpreted and / or parsed? I've also read a string in C is really an array of chars in an article I fou...

jQuery/Javascript: string splitting question

hi all, i'd like to split an image's href tag like <img src='/root/myimages/myPic.jpg'> so that i'm getting just myPic.jpg - whats the easiest way? thx ...

Convert String To date in PHP

How can I convert this string 05/Feb/2010:14:00:01 to unixtime ? ...

C# Static class vs struct for predefined strings

A co-worker just created the following construction in C# (the example code is simplified). His goal was to shorten the notation for all predefined strings in the rest of the code. public struct PredefinedStrings { public const string VeryLongName = "Very Long Name"; public const string AnotherVeryLongName = "Another Very Long N...