string

jQuery to trigger event through query string

I have two separate jQuery functions that allow a user to toggle a div's visibility. By defualt, the divs will be in their closed state. I'm trying to figure out a way to set up links to this page that will open a specific div based on an ID passed to the query string. My jQuery looks like this: jQuery(document).ready(function(){ ...

How to filter characters from a string with C++/Boost

Hello, This seems like such a basic question, so I apologize if it's already been answered somewhere (my searching didn't turn up anything). I just want to filter a string object so that it contains only alphanumeric and space characters. Here's what I tried: #include "boost/algorithm/string/erase.hpp" #include "boost/algorithm/strin...

Number of seconds in "HH:MM:SS"

What's the best way to get the number of seconds in a string representation like "hh:mm:ss"? Obviously Integer.parseInt(s.substring(...)) * 3600 + Integer.parseInt(s.substring(...)) * 60 + Integer.parseInt(s.substring(...)) works. But I don't want to test that, and reinvent the wheal, I expect there is a way to use DateTimeFormat or...

C# Converting set flags in a variable of type flag enumeration to an array of integers

I came up with this piece of code that converts the set flags in a variable of type Flag Enumeration and returns the set flags as integers. I'd like to know if this is the best approach. Example enumeration: [Flags] enum Status { None = 0x0, Active = 0x1, Inactive = 0x2, Canceled = 0x4, Suspended = 0x8 } The extension method...

how to use reflection in C# to list the methods of an .asmx

given a url that references an asmx how would i go about displaying all of their method names? if assembly="http://.../something/something.asmx" and i was trying to display the method names of that service what should i do now that i have gotten myself this far? i cant seem to find a solution among the hundreds of examples ive looked at...

Counting spaces infront of a String

Hello, Recently I asked this question: http://stackoverflow.com/questions/3199449/removing-up-to-4-spaces-from-a-string and it works just fine. I am interested however in counting the number of spaces I have removed as well. How can I do this? Count the number of spaces removed using this? stringArray[i] = stringArray[i].replaceFirst ...

PHP - Remove <span> tag from string

I have a string with this html: <div> <span> 1 </span> <a href="#"> <span> 2 </span> </a> <a href="#"> <span> 3 </span> </a> <a href="#"> <span> 4 </span> </a> .... </div> how do I remove the <span> tags from inside the links (<a>) ? ...

Efficient algorithm to find String overlaps.

I won't go into the details of the problem I'm trying to solve, but it deals with a large string and involves finding overlapping intervals that exist in the string. I can only use one of the intervals that overlap, so I wanted to separate these intervals out and analyze them individually. I was wondering what algorithm to use to do this...

Remove extra zeros when converting a double to a string in Objective C

So when I convert a double to a string using something like this: double number = 1.1; text = [[NSString alloc] initWithFormat:@"%f", number]; The variable text ends up printing something like this: 1.100000. I realize that this is because of the way the computer stores the value however I need an easy way to remove those extra zeros ...

regular expression: replace match with its index

How can I transform the string "a b a c d a a" into the string "1 b 2 c d 3 4" with a regular expression? Is this possible? Preferred flavor is perl, but any other will do too. s/a/ \????? /g ...

How to Convert string (culture != "en-US") to int C# 2005

C# 2005, I have set the culture like below in Program.cs: CultureInfo myCulture = new CultureInfo("bn-IN");// like "en-US", "ja-JP" etc... Thread.CurrentThread.CurrentCulture = myCulture; Thread.CurrentThread.CurrentUICulture = myCulture; Application.CurrentCulture = myCulture; Then after opening the application I choose my keyboard, ...

g++ __FUNCTION__ replace time

Hi, can anyone tell when g++ replaces the __FUNCTION__ 'macro' with the string containing the function name? It seems it can replace it not until it has check the syntactical correctness of the source code, i.e. the following will not work #include <whatsneeded> #define DBG_WHEREAMI __FUNCTION__ __FILE__ __LINE__ int main(int argc, ch...

Splitting a space separated list..

This is a common task I'm facing: splitting a space separated list into a head element and an array containing the tail elements. For example, given this string: the quick brown fox We want: "the" ["quick","brown","fox"] .. in two different variables. The first variable should be a string, and the second an array. I'm looking for a...

Elegant parsing of this? "a,b,c",d,"e,f"

I'm looking to parse these kinds of strings into lists in Python: "a,b,c",d,"e,f" => ['a','b','c'] , ['d'] , ['e','f'] "a,b,c",d,e => ['a','b','c'] , ['d'] , ['e'] a,b,"c,d,e,f" => ['a'],['b'],['c','d','e','f'] a,"b,c,d",{x(a,b,c-d)} => ['a'],['b','c','d'],[('x',['a'],['b'],['c-d'])] It nests, so I suspe...

How to get ° charater in a string in python?

How can I get a ° character into a string? ...

initializing char arrays in a way similar to initializing string literals

Suppose I've following initialization of a char array: char charArray[]={'h','e','l','l','o',' ','w','o','r','l','d'}; and I also have following initialization of a string literal: char stringLiteral[]="hello world"; The only difference between contents of first array and second string is that second string's got a null charact...

C++ Mysql Real Escape String Issue

Hmm, for some reason, its only doing this on the first username (and password) and does it for how big my my vector is. Any ideas on why? int eMysql::strip(string &input) { char* from = new char[strlen(input.c_str()) * 3 + 1]; mysql_real_escape_string(&mysql, from, input.c_str(), input.length()); input = input.assign(from); ...

Java Quotation Matching

Hello all, I'm not sure if this is a regex question, but i need to be able to grab whats inside single qoutes, and surround them with something. For example: this is a 'test' of 'something' and 'I' 'really' want 'to' 'solve this' would turn into this is a ('test') of ('something') and ('I') ('really') want ('to') ('solve this') A...

Converting a byte array to string without using new operator in Java

Hi All, Is there a way to convert a byte array to string other than using new String(bytearray)? The exact problem is I transmit a json-formatted string over the network through UDP connection. At the other end, I receive it in a fixed-size byte array(as I am not aware of the array size) and create a new string out of the byte array. I...

Javascript, String formatting: I need the first 4 letters of a string, lowercase, whitespace skimmed, symbols removed...

...I should just list them: First 4 letters/numbers, with... All lowercase. Whitespace stripped. Symbols removed. Should be simple. What's the best way to do this? ...