Possible Duplicate:
Parsing formatted string.
How can I use a String.Format format and transform its output to its inputs?
For example:
string formatString = "My name is {0}. I have {1} cow(s).";
string s = String.Format(formatString, "strager", 2);
// Call the magic method...
ICollection<string> parts = String.ReverseForma...
I have a class that encrypts and decrypts a string. It uses rijndael. Anyways, I am trying to store an encrypted value on the client. That works all fine and dandy. My problem is when I want to decrypt the value, I need the Key and IV(InitVector) that was used to encrypt the string. They are byte[] values. I currently output those to the...
So pray tell, how would I go about getting the largest contiguous string of letters out of a string of garbage in C? Here's an example:
char *s = "(2034HEY!!11 th[]thisiswhatwewant44";
Would return...
thisiswhatwewant
I had this on a quiz the other day...and it drove me nuts (still is) trying to figure it out!
UPDATE:
My fault...
Hello, I am writing a small program to do some calculations.
Basically the input is the following:
-91 10 -4 5
The digits can have the negative sign or not. They are also separated by a space.
I need a regular expression to filter each digit including the sign if there is one.
Thanks!
Adam
...
How do I make the following string cast:
"ln(5*x)" -> "Math.log(5*x)"
...
Possible Duplicate:
How to extract img src, title and alt from html using php?
Hi,
I have found solution to get first image from string:
preg_match('~<img[^>]*src\s?=\s?[\'"]([^\'"]*)~i',$string, $matches);
But I can't manage to get all images from string.
One more thing... If image contains alternative text (alt attribute) h...
if($xmlobj = simplexml_load_string(file_get_contents($xml_feed)))
{
$result = $xmlobj->xpath("TrafficMeta");
}
The above code returns the desired result and when viewed with print_r it shows this, which is what I want to get (sessionId):
Array ( [0] => SimpleXMLElement Object ( [sessionId] => tbfm1t45xplzrongbtbdyfa5 ) )
How ca...
Does anyone else think that escaping characters in very short strings make them not very readable? I noticed I was using s = "\"" in my code to assign a double quote a string, but having thought about it, I came up with the following alternative: s = '"'.ToString().
Is my alternative any good? Would you prefer see the first version in ...
I have a file that looks like this:
A B C D E
0 8 6 12 5
8 0 10 8 9
6 10 0 7 11
12 8 7 0 6
5 9 11 6 0
I don't know ahead of time how many rows and columns there will be. I would like to read the top line, which will let me know the number of rows to expect . I found lisp's (read <stream>) function which, in a loop, can parse each of t...
What C function, if any, removes all preceding spaces and tabs from a string?
Thanks.
...
I'm playing around with using some javascript to add extra functionality to a back button on my website. Right now I have a set of javascript that looks like this:
$(".back-link a").live("click", function(){
history.go(-1);
return false;
});
Now, it works great but I'm trying to make it as bulletproof as possible and one issue...
How can I strip a string with all \n and \t in C?
...
Hello again.
I have the following code:
$array = parse_url($_SERVER['HTTP_REFERER']);
$Ur = $array['host'];
which displays the domain just fine, but when I use this with sessions, it doesn't work. Also, I tested it with gettype and it returns Null? I thought it was an array?
Anywho, how do I go about converting the above $Ur into a...
Suppose I have this table:
ID | description
-------------------
5 | The bird flew over the tree.
2 | The birds, flew over the tree
These two rows have "similar" content. How would I remove #2?
What algorithm should I use for "similar" text?
How would I do this with Python?
Thanks!
...
I understand that the String class' hashCode() method is not guarantied to generate unique hash codes for distinct String-s. I see a lot of usage of putting String keys into HashMap-s (using the default String hashCode() method). A lot of this usage could result in significant application issues if a map put displaced a HashMap entry t...
Learning JS this week.
Is it possible to use Math.random to return a random value in an array? Does that value be a string and still work?
...
I was using std::hash_map<char*,T> and somehow managed to make it work but have now discovered that the default compare function, euqal_to<char*> does a pointer compare rather than a string compare. I've fixed this by making my own compare type (using C's strcmp and it's about 5 LOC) but I'd be slightly shocked if there wasn't one alread...
why php's str_replace and many other string functions mess up the strings with special chars such ('é' 'à' ..) ? and how to fix this problem ?
...
Hey fellas...
OK, a recent quiz entry tasked the student with writing a method 'longhead' (char *longhead) that would return a string consisting of the concatenation of all of the heads in a given string. Example:
char *string = "this";
printf("%s\n", longhead(string));
OUTPUT: tththithis
I did come up with a solution, but it works ...
I am using the toString method of ArrayList to store ArrayList data into a String. My question is, how do I go the other way? Is there an existing method that will parse the data in the String back into an ArrayList?
...