Was asked this in an interview, my solution kinda sucked so I am wondering if anyone can do better.
Given a URL string in this form:
http://www.foo.com?key1=value1&key2=value2&key3=value3 and given a key
I want to create a function that takes a key value and returns the original string WITHOUT the key and value.
Example:
in...
Hi:
I am programing VIX API from python 2.5, but now I want to port the code to python 3.2
This funtion opens the virtual machine:
self.jobHandle = self.VixLib.vix.VixVM_Open(self.hostHandle,
"C:\\MyVirtualMachine.vmx",
None,
None)e...
Hello everyone!
I would like to know whether there is a way to insert/inject a <string> element defined in an XML file into another <string> element, doing that just with XML.
For example I could have:
<string name="author">Francesco</string>`
and I am looking for something like:
<string name="about_application">Author: @string/aut...
Hi,
I've got a broken web service that I can't access and alter. It sends down some mainly nice JSON, but one of the attributes is a nested JSON object that is being sent down as a string.
http://www.ireland.com/api/getitemweb/185213
CustomJsonData in the response from the above url is the example.
My question is how could I interpret...
Consider the following snippet:
>>> def foo(port, out, udp=False, ipv6=False, data=''):
... if not data:
... data = 'foo {family} {:port} {direction}'.format(
... family=('ipv6' if ipv6 else 'ipv4'),
... port=port,
... direction=('out' if...
Possible Duplicate:
Why does this Seg Fault?
Hello, I have a
char* str = "blah";
And I now want to change one of the characters to something else, say a number 3. I am trying to do so with:
str[2] = '3';
However I am getting a seg fault at this line of code. Any idea why?
...
I am getting a string from Twitter into my Actionscript which is a unformatted string. I want to be able to extract any links and or any @replies from the string, then display it in htmlText.
So far I have this
var txt:String = "This is just some text http://www.thisisawebsite.com and some more text via @sumTwitter";
var twitterText:...
I have the following strings in a text file "test"
Table Name.type
Market Drinks.tea
I wana split the strings so that I get the following output
ObjectName = Table AttributeName = Name Attribute Type =type
ObjectName = Market AttributeName = Drinks Attribute Type =tea
here is my code
string[] lines = File.Read...
Hello,
I want to know the positions of the "_" in a string:
string str("BLA_BLABLA_BLA.txt");
Something like:
string::iterator it;
for ( it=str.begin() ; it < str.end(); it++ ){
if (*it == "_") //this goes wrong: pointer and integer comparison
{
pos(1) = it;
}
cout << *it << endl;
}
Thanks,
André
...
I have 2 sources of information for the same data (companies), which I can join together via a unique ID (contract number). The presence of the second, different source, is due to the fact that the 2 sources are updated manually, independently. So what I have is an ID and a company Name in 2 tables.
I need to come up with an algorithm t...
Hi,
I have textbox in c#, contains two or three strings with white spaces. i want to store those strings seperately.please, suggest me any code. thanx.
...
Hello,
I need to check a string to see if it contains another string.
var str1 = "ABCDEFGHIJKLMNOP";
var str2 = "DEFG";
What function do I use to find out if str1 contains str2?
Cheers,
Thomas.
...
I'm writing a linux shell for my operating systems class. I've knocked out the majority of it but I'm stuck on simple string comparisons. I've everything I can think of. strcmp should take in \0 terminated strings and return 0 for equal but that doesn't seem to be working and even stepping through the array and checking each char isn'...
I have a large set (100k) of short strings (not more than 100 chars) and I need to quickly find all those who have a certain substring.
This will be used as a search box where the user starts typing and the system immediately gives "suggestions" (the strings that have as a substring the text that the user typed). Something similar to th...
In Java, I have an array of integers. Is there a quick way to convert them to a string?
I.E. int[] x = new int[] {3,4,5}
x toString() should yield "345"
...
I'm working on a simple MySQL full-text search feature on a CakePHP site, and noticed that MySQL strips short words (3 chars or less) out of the query. Some of the items in the site have 3 character titles, however, and I'd like to include them in the results. (I've ruled out using more robust search appliances like Solr due to budget co...
Is there a way to sort an array of strings in alphabetical order where the strings contain both capital and lowercase letters?
Because capital letters have a lower ASCII value so functions like strcmp would always show that it is before a lower case letter. For example, lets say we wanted to sort "ABCD", "ZZZZ", "turtle", "JAVA", "wate...
How can I get the byte sequence of a particular UTF-8 string? I'm seeing what looks like some bug in the regex engine which is only triggered in some edge cases, and I'd like to know exactly what data it's working on.
...
Hi,
The following shell sessions shows some behavior I would like to understand:
1> A = "Some text".
"Some text"
2> "Some " ++ R = A.
"Some text"
3> R.
"text"
4> B = "Some ".
"Some "
5> B ++ L = A.
* 1: illegal pattern
Surely statements 2 and 5 are syntacticially identical? I would like to use this idiom to extract some text from a s...
How can I replace the contents of strings with #'s in Python? Assume no comments, no multiple lines for one string. Like if there is a line in a python file:
print 'Hello' + "her mom's shirt".
This will be translated into:
print '#####' + "###############".
It's like a filter to deal with every line in a python file.
...