string

Referring to class names through strings?

I need to parse some text file, create objects for various entities encountered in the text, and put them in some data structure (e.g., a list) for further processing. Example of the text: laptop 17" dell, weight: 12 lb desktop 24" hp I know in advance which entities may exist in the text, and what attributes they are supposed to ha...

c# - How to produce string with 'and' in the correct place.

Here is the loop I have so far foreach (CheckBox chk in gpbSchedule.Controls.OfType<CheckBox>()) { if (chk.Checked) { //Code goes here } } The checkboxes all have text values of the days of the week. Monday, Tuesday ect....

What is the proper way of implementing a good "itoa()" function ?

First, hi, I'm new to stackoverflow ! Well, I was wondering if my implementation of an "itoa" function is correct. Maybe you can help me getting it a bit more "correct", I'm pretty sure I'm missing something. (Maybe there is already a library doing the conversion the way I want it to do, but... couldn't find any) #include <stdio.h> #in...

PHP string split

Hi, I have this $str value : [{\"firstname\":\"guest1\",\"lastname\":\"one\",\"age\":\"22\",\"gender\":\"Male\"},{\"firstname\":\"guest2\",\"lastname\":\"two\",\"age\":\"22\",\"gender\":\"Female\"}] I want to split it into the following: firstname:guest1,lastname:one,age:22 firstname:guest2,lastname:two,age:22 I tried explode (","...

PHP replace string

$name (string) gives something like (possible value): John II, Litten Draw We should update $name in two steps: Catch the words before first comma and throw them to the end of the string Remove first comma Create a file current_name.txt (or update if already exists) and throw to it source of $name "John II, Litten Draw" should be ...

API For KMP or Boyer-Moore string pattern matching in C++ / STL?

Wondering, if I want to replace strstr with a better string matching algorithm, like KMP or Boyer Moore, is there one in C++ or do we have to write on our own? Wondering, what is the practical string matching function that everyone uses other than strstr? This is with respect to C++/STL under Unix/Linux platform. ...

PHP strip string

$var = 'Click on this <a href="#">link</a>. (goes to heaven) (and then somewhere else)'; How to get the text, which is placed between first brackets? Throw its value to $extra In this example $extra = 'goes to heaven' Thanks. ...

iPhone SDK - convert strings to call variable names

Ok, I got used to coding with PHP. I'm currently trying to do a sudoku app. Now I'm coming to a point where I need to show the proper number in the appropriate cell (UITextfield) based on the number pressed. (I have 9 buttons that correspond to 1-9 respectively) Conceptually when the used clicks on a cell, I want to: 1. put the UITextFi...

PHP string letters

We have a variable $string, its contains some text like: About 200 million CAPTCHAs are solved by humans around the world every day. How can we get 2-3 last or first letters of each word (which length is more than 3 letters)? Will check them for matched text with foreach(): if ('ey' is matched in the end of some word) { replace 'e...

How to convert a string with date and time to DateTime data type ?

A client is sending a string containing a date in format YYYYMMDDHHmmSS (e.g. 201004224432). There are no separators like / or -. How can I easily convert this to a DateTime object? Convert.ToDateTime() does not work. ...

bash line concatenation during variable interpolation

$ cat isbndb.sample | wc -l 13 $ var=$(cat isbndb.sample); echo $var | wc -l 1 Why is the newline character missing when I assign the string to the variable? How can I keep the newline character from being converted into a space? I am using bash. ...

How can I check if a string I have returned from a cursor is emtpy or null in an Android cursor?

This is my code, it always falls into the else even when I know that the value going in (via debugger) is emtpy. name = cursor.getString(cursor.getColumnIndex("Genus")) + " " + cursor.getString(cursor.getColumnIndex("Species")); if(name != "" && name != null) tv.setText(name); else tv.setText("Error"); ...

How to find double quotes in string in C#

If a string has double quotes, string str = "it is a "text"" how can I find out if the string have " or not. And how can the double quotes be removed? ...

Difference between single quote and double quote string in php

Hi, I'm not a major in PHP programming but I'm a little confused why I see some codes in PHP with string placed in single quote and sometimes in double quote. I just know in .NET, or C language, if it is in single quote, that means it is a character, not a string. ...

How can I count the number of newline characters at the end of a string in javascript?

For example I have a string that looks like the following: var example_string = "this is the example string\n <-don't want \n\n\n"; Here I've made a string that has four newline characters in it, with three consecutive on the end. How can I programmatically have javascript tell me that there are 3 newline characters on the end? ...

Qt localization: loading the localizable string probelm

Hi, i want to load the localized string in Qt application. for this i am following few steps, correct me if i am wrong. Note: it works fine for QString but not for const char* 1)update the pro file with translation language 2)generate .ts & edit using Qt linguist. Generate .qm file using lupdate and lrelease. 3)load the .qm file from ...

Case sensitive string comparison in C++

Can anyone pls let me know the exact c++ code of case sensitive comparison function of string class? ...

php creating editing and writing files

Im trying to use file_get_contents to get contents of a file and delete a certain part of a line in that file. Is the following anywhere near what I want to achieve? $page = file_get_contents('myPage.php?id='.$_GET['id']); $file = 'temp/form_'.$_GET['id'].'.html'; $change = file_get_contents('myPage.php?id='.$_GET['id']); $cha...

Search Directory for Files that start with ACCESS and then search that file

I need to use C# to search a directory (C:\Logs) for log files whose name starts with ACCESS. Once I find a file that begins with ACCESS I need to search that file and make a collection of strings that start with Identity=" " An example would be Identity="SWN\smithj" so I need everything from Identity to the last double quotes collecte...

When are Java Strings interned?

Inspired by the comments on this question, I'm pretty sure that Java Strings are interned at runtime rather than compile time - surely just the fact that classes can be compiled at different times, but would still point to the same reference at runtime. I can't seem to find any evidence to back this up. Can anyone justify this? ...