string

String.split() method bug in GWT 2.0.3

I'm upgrading a GWT project from GWT 1.7.1 to currently newest version 2.0.3. It seems that new GWT broke String.split(String regex) method - I get the following error on the Javascript side: this$static is undefined This happens in this line of my .nocache.js file: if (maxMatch == 0 && this$static.length > 0) { ...which happens to...

Need to parse a string till the end of the file

i have the following code ..i need to loop through end of the file as per the commented code shown below how i can do it ? namespace BVParser { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { StreamReader sr = new StreamReader(@"D:\Jaison\Ja...

c# string manipulation

i have string of 9 letters. string myString = "123987898"; I want to retrieve frist 3 letter "123" then 2 more leters "98" and then 4 more letters "7898". Which c# string function support this functionality. ...

C: How to convert a string of ints into actual ints and store them in an array?

I have a string "14 22 33 48". I need to insert each of the values in the string into the respective location in the array: int matrix[5]; so that matrix[0] = 14; matrix[1] = 22; matrix[2] = 33; matrix[3] = 48; How do I do this? ...

casting raw strings python

in python, given a variable which holds a string is there a quick way to cast that into another raw string variable? the following code should illustrate what im after... def checkEqual(x, y): print True if x==y else False line1 = "hurr..\n..durr" line2 = r"hurr..\n..durr" line3 = "%r"%line1 print "%s \n\n%s \n\n%s \n" % (line1, ...

In Java how does one turn a String into a char or a char into a String?

Is there a way to turn a char into a String or a String with one letter into a char (like how you can turn an int into a double and a double into an int)? (please link to the relevant documentation if you can). How do I go about finding something like this that I'm only vaguely aware of in the documentation? ...

Javascript - Determine if String Is In List

In SQL we can see if a string is in a list like so: Column IN ('a', 'b', 'c') What's a good way to do this in javascript? I realize one can use the switch function: var str = 'a' var flag = false; switch (str) { case 'a': case 'b': case 'c': flag = true; default: } if (thisthing || thatthing || flag === true) { ...

Weird problem with string function

I'm having a weird problem with the following function, which returns a string with all the characters in it after a certain point: string after(int after, string word) { char temp[word.size() - after]; cout << word.size() - after << endl; //output here is as expected for(int a = 0; a < (word.size() - after); a++) { ...

Best practices for handling string in VC++?

As I am new to Visual C++, there are so many types for handling string. When I use some type and go ahead with coding but on next step, there are in-build functions that use other types & it always require to convert one type of string to other. I found so many blogs but so confused when see so many answers & try but some are working & s...

java outOfMemoryError with stringbuilder

I'm getting a java outOfMemoryError when I call this method - i'm using it in a loop to parse many large files in sequence. my guess is that result.toString() is not getting garbage collected properly during the loop. if so, how should i fix it? private String matchHelper(String buffer, String regex, String method){ Pattern abbrev_p...

Garbage collection behaviour for String.intern()

If I use String.intern() to improve performance as I can use "==" to compare interned string, will I run into garbage collection issues. How does the garbage collection mechanism of interned strings differ from normal strings ? ...

iphone sqlite3_column_text issue

I have a column in sqlite3 table. Column has values like 1 ½” 1 ¾” 2 ½” etc. Column has VARCHAR datatype. I am using this code. pref_HoseDiameter = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 2)]; Now, when I am fetching these values from database, I am getting pref_HoseDiameter string values li...

How to capitalize the first word of the sentece in Objective C?

I've already found how to capitalize all words of the sentence, but not the first word only. NSString *txt =@"hi my friends!" [txt capitalizedString]; I don't want to change to lower case and capitalize the first char. I'd like to capitalize the first word only without change the others. ...

Turning temporary stringstream to c_str() in single statement

Consider the following function: void f(const char* str); Suppose I want to generate a string using stringstream and pass it to this function. If I want to do it in one statement, I might try: f((std::ostringstream() << "Value: " << 5).str().c_str()); // error This gives an error: 'str()' is not a member of 'basic_ostream'. OK, s...

Object for storing strings in Python

class MyWriter: def __init__(self, stdout): self.stdout = stdout self.dumps = [] def write(self, text): self.stdout.write(smart_unicode(text).encode('cp1251')) self.dumps.append(text) def close(self): self.stdout.close() writer = MyWriter(sys.stdout) save = sys.stdout sys.stdout ...

Nil string with [NSString stringWithFormat:] appears as "(null)"

I have a 'Contact' class with two properties : firstName and lastName. When I want to display a contact's full name, here is what I do: NSString *fullName = [NSString stringWithFormat:@"%@ %@", contact.firstName, contact.lastName]; But when the firstName and/or lastName is set to nil, I get a "(null)" in the fullName string. To preven...

Python to MATLAB: exporting list of strings using scipy.io

I am trying to export a list of text strings from Python to MATLAB using scipy.io. I would like to use scipy.io because my desired .mat file should include both numerical matrices (which I learned to do here) and text cell arrays. I tried: import scipy.io my_list = ['abc', 'def', 'ghi'] scipy.io.savemat('test.mat', mdict={'my_list': my...

Converting a string to a mySql DECIMAL type

I am trying to insert data about an item's price from an HTML form into a mySQL database. The input field is defined as follows: <input type="text" name="price" value="0.00"/> The form is POSTed to the next page in which the database stuff is taken care of. Currently I just enter the exact contents of $_POST['price'] into the database...

Obtaining reference to Class instance by string name - VB.NET

Is it possible using Reflection or some other method to obtain a reference to a specific class instance from the name of that class instance? For example the framework for the applications i develop heavily uses public class instances such as: Public bMyreference as MyReference = new MyReference Then throughout the application bMyRef...

Serialize an object to string

I have the following method to save an Object to a file: // Save an object out to the disk public static void SerializeObject<T>(this T toSerialize, String filename) { XmlSerializer xmlSerializer = new XmlSerializer(toSerialize.GetType()); TextWriter textWriter = new StreamWriter(filename); xmlSerializer.Serialize(textWrite...