string

How to strip leading and trailing quote from string, in Ruby

I want to strip leading and trailing quotes, in Ruby, from a string. The quote character will occur 0 or 1 time. For example, all of the following should be converted to foo,bar: "foo,bar" "foo,bar foo,bar" foo,bar ...

Storing price in PHP. What is better double or string?

I've been making "Product Object" for my app and I've been setting attributes, when suddenly I got to price attribute and stumbled upon it with question what type better to choose? I understand, that for PHP it doesn't matter so much, but lets say for MySQL it does. Any suggestions? ...

objective-c string, string-formatter

I have a program with which dreamlax worked a lot with me on, which uses Objective-C to convert temperatures between the Fahrenheit, Celsius, Kelvin and Rankine temperature scales, but converting console-input into Kelvin, and then from Kelvin to the end-user's desired temperature scale. Now, I have an idea I would like to implement for...

PHP: Find and exctract into an array all instances of specific text in a string.

Hi All, I have a string that contains several "placeholders" in it, and each placeholder is marked with this syntax: {value}. I want to be able to pull out each placeholder within the string and load them into an array. For example, if I had this string here... "this is a {test} string, to demonstrate my {objective}." I would want t...

whats the difference between C strings and C++ strings?

whats the difference between C Strings and C++ strings. Specially while doing dynamic memory allocation ...

Printing a C string in reverse without using pointers?

Is there a way to print a string of fixed size in reverse without using pointers? #include<stdio.h> main() { char buffer[10]; scanf("%s", buffer); // need to print buffer in reverse without using pointers?? } ...

How to efficiently overwrite parts of a string by index in .NET ?

Hi, In my .NET program I allow a user to define "fields" which are values calculated by the business logic. These fields have a position and length, so that they can all be inserted into a single output string at a given index. I also allow a user to specify default content of this output string. If no field is defined to replace a give...

How to create a std::wstring using the ascii codes of characters in C++?

I need to create a wstring with the chars that have the following ascii values: 30, 29, 28, 27, 26, 25. In VB6, I would do asc(30) + asc(29)+ etc... What's the C++ equivalent? Thanks! ...

Java String; Able to allocate the size of the string given a size?

Hi. Tried searching in the Java String API with no answer. I am trying to create Java strings with a specified size. I noticed that Java Strings do not end in the null character (\0). Basically, I would like to be able to create strings such as: String myString = new String("Charles", 32); where myString will contain "Charles ...

If Not String.Empty ignoring empty string - VB.NET

I have a array of strings and I am looping through them, but the string might be empty so I am trying this: For Each Component As String In Components If Component IsNot String.Empty Then 'Work your magic End If Next But if Component is an empty string the logic still fires. I've also tried If Component <> "" Then E...

Named namespace in implementation file to group const string literals - Good/Bad?

I've grouped several message strings into a named (non anonymous) namespace in the .cpp file for a class handling output as seen in the code below: namespace Messages { static const std::string AppTitle = "The Widgetizer - Serving all your Widget needs"; static const std::string SuccessMsg = "Great success! Widgets for all! "; sta...

Run length encoding of hexadecimal strings including newlines.

I am implementing run length encoding using the GZipStream class in a C# winforms app. Data is provided as a series of strings separated by newline characters, like this: FFFFFFFF FFFFFEFF FDFFFFFF 00FFFFFF Before compressing, I convert the string to a byte array, but doing so fails if newline characters are present. Each newline is...

Convert a String (formatted just like an ArrayList<String>) to an actual ArrayList<String>

Hi, I am trying to convert a String into an ArrayList. For example, my Struts2 webapp returns this String named row in a format similar to this: [A, BB, CCC, DDDD, 1, 0, 1] (something along those lines) I need to convert them into an ArrayList so I can prepopulate some forms in another JSP page. I hardcoded a method to convert such St...

jQuery - better way to concatenate strings that have quotations?

Is there a better way to concatenate strings that have "'s (such as HTML tag attribute definitions) in jQuery than escaping the quote? Escapy Example: $(this).prepend("<label for=\""+$(this).attr("id")+"\">"+"a"+"</label>"); ...

what's the use of string.Clone() ?

there are 2 examples of code: # 1 string str1 = "hello"; string str2 = str1; //reference to the same string str1 = "bye"; //new string created and # 2 string str3 = "hello"; string str4 = (string)str3.Clone();//reference to the same string str3 = "bye";//new string created looks like they are identical aren't they? so what is ...

Time of Strings Creation in Java

Hi there! I am writing an app for J2ME devices and pretty much care about unnecessary String creation. As working with Strings is built-in, i.e. it is not necessary to create them explicitly, I am not sure if I understand it right. For instance returning a String (just by using the double quotes) creates the string when it is being ret...

Formatting string for xml attribute in php

I have some strings that are valid in my database but when I include them in an attribute of a UTF-8 XML output they give me the following error: XML Parsing Error: not well-formed My current code (simplified): header('Content-Type: text/xml'); echo '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'; echo '<root attribute=...

Question on searching a string using regex and storing in a List..

Hello All- Below is code used to search a string where Identity=" " exists and stores that line in a List. I need to add to this search so that it not only picks up Identity=" " but ALSO where FrameworkSiteID=" ". How can I modify the below code to do this? Many thanks. List<KeyValuePair<string, string>> IdentityLines = new List<Key...

Split one string into different strings

i have the text in a string as shown below 011597464952,01521545545,454545474,454545444|Hello this is were the message is. Basically i would like each of the numbers in different strings to the message eg NSString *Number1 = 011597464952 NSString *Number2 = 01521545545 etc etc NSString *Message = Hello this is were the message is. ...

Perl elsif not being evaulated

Anyone see anything wrong with this code? When we execute it (on Linux), we get taken straight to the "Error: Unknown host" block. Perl is version 5.8.6 $hostname = "host2"; if ($hostname eq "host1") { $dbhost = 'dbi:Oracle:dbhost1'; } elsif ($hostname eq "host2") { $dbhost = 'dbi:Oracle:dbhost2'; } elsif ($hostname eq "host3" |...