I'm trying to write a function that takes a string representing a namespace (e.g. "MyCompany.UI.LoginPage") and defines each segment of the namespace as an object if it doesn't already exist. For example, if "MyCompany.UI.LoginPage" wasn't an object, it would evaluate this:
MyCompany = {};
MyCompany.UI = {};
MyCompany.UI.LoginPage = {};...
I have a string that contains an array that i would like to convert into an array. How would you do this?
I want to convert this:
myvar=
"[[Date.UTC(2010, 0, 23),0],[Date.UTC(2010, 0, 24),0],[Date.UTC(2010, 0, 25),3],[Date.UTC(2010, 0, 26),0],[Date.UTC(2010, 0, 27),0],[Date.UTC(2010, 0, 28),0],[Date.UTC(2010, 0, 29),0],[Date.UTC(2010,...
I am trying to convert strings into Inetaddress. I am not trying to resolve hostnames, the strings are ipv4 addresses, does InetAddress.getByName(String host) work? Or do I have to manually parse it?
...
main()
{
....
i = index;
while (i < j)
{
if (ip[i] == "/")
{
ip[i - 1] = (double.Parse(ip[i - 1]) / double.Parse(ip[i + 1])).ToString();
for (int k = i; k < (ip.Length - 2); k++)
{
ip[k] = ip[k + 2];
}
Array.Resize(ref i...
I noticed in the Java 6 source code for String that hashCode only caches values other than 0. The difference in performance is exhibited by the following snippet:
public class Main{
static void test(String s) {
long start = System.currentTimeMillis();
for (int i = 0; i < 10000000; i++) {
s.hashCode();
}
...
I'm trying to parse a delimited string using the javascript split function. I'm using a double character delimiter.
So for e.g. if the string contains employee related data with the following fields:
Emp Id (mandatory)
Name (mandatory)
Age (optional)
Mobile No (optional)
and the delimiter used is |* (i.e. pipe followed by star)
I m...
Hi!
How can I remove last character from a C++ string?
I tried st = substr(st.length()-1); But it didn't work.
...
Hello,
a brain dead third party program I'm forced to use determines how to treat paths depending if the input supplied is a single word, or a full path: in the former case, the path is interpreted relative to some obscure root directory.
So, given that the input can be a full or relative path, or a single word (including underscores ...
If I have a dictionary full of nested stuff, how do I store that in a database, as a string? and then, convert it back to a dictionary when I'm ready to parse?
Edit: I just want to convert it to a string...and then back to a dictionary.
...
hi, it is possible to convert in iphone sdk (obj-c) a string to nsdate.
thank you
...
What could generate the following behavior ?
>>> print str(msg)
my message
>>> print unicode(msg)
my message
But:
>>> print '%s' % msg
another message
More info:
my msg object is inherited from unicode.
the methods __str__/__unicode__/__repr__ methods were overridden to return the string 'my message'.
the msg object was initiali...
I am building a comment notification system in Rails and I am trying to render user provided comments in a plain text email.
When I render the comment, I want to auto wrap the lines when 56 characters are reached. Obviously I don't want to split words.
Is there a function in Ruby or RoR for doing this, or do I need to roll my own?
Qu...
Hi,
My code:
stringFromRecievedData =
[[NSString alloc]initWithData:_data1 encoding:NSUTF8StringEncoding];
if (![stringFromRecievedData isEqualToString:lastStringFromRecievedData]) {
[lastStringFromRecievedData setString: stringFromRecievedData];
I get the same "not equal" result even in the second round- even when it is the...
I have a map that represents a DB object. I want to get 'well known' values from it
std::map<std::string, std::string> dbo;
...
std::string val = map["foo"];
all fine but it strikes me that "foo" is being converted to a temporary string on every call. Surely it would be better to have a constant std::string (of course its probably ...
Hi all,
I've got a div that looks like this:
<div id="exampleDiv" class="class1 class2" title="example title"></div>
I've selected with JQuery using this statement:
var $div = $('#exampleDiv');
What I'd like to get is a string of the tag itself as html, so that I actually get:
"<div id='exampleDiv' class='class1'....", etc.
Doe...
I have a String2. I want to check whether String2 exists in String1. String1's length can be less or greater or equal than String2. Also String2 can be null or empty sometimes. How can I check this in my Java code?
...
I'm bad with strings and probably messed this up. My Flash file receives XML commands and changes the value of the animations (speed, time). Can you improve this string argument or give me an idea what I need to do differently.
XML
<head>
</head>
<body>
<cnt>1count*count/10</cnt>
</body>
IS THIS RIGHT?
...
Is there a .Net function that does that. I guess if there isn't i have to make my own method.
The thing is i have a function. It accepts integers. If you pass a 0 integer or a null value it still works. Problem is that the value of an empty textbox is a String.Empty value.
I don't want to use if's. I mean it could but its much nicer i...
I am new to C89, and don't really understand how strings work. I am developing on Windows 7.
Here is what I am trying to do, in Java:
String hostname = url.substring(7, url.indexOf('/'));
Here is my clumsy attempt to do this in C89:
// well formed url ensured
void get(char *url) {
int hostnameLength;
char *firstSlash;
ch...
I'm experiencing a very strange issue with string equality in SQLite3. I have a table with a text column named type.
If I run select distinct type, 2 from mytable order by type (the 2 is there to get the pipe separator), I get:
...
Tops|2
...
Tops|2
i.e., the same column appears twice. This is causing me problems because queries wi...