views:

40

answers:

2
$(this).html().replace("0 days","");

i want to replace "0 days" to become "". Currently the above statement will replace "0" to "" . that is not what i want. i want to replace entire statement "0 days"

+3  A: 

This will replace only the first occurrence. If you want to replace all occurrences:

$(this).html().replace(/0 days/g, '');

Example:

alert('foo 0 days bar 0 days foobar'.replace(/0 days/g, ''));

shows:

foo bar foobar
Darin Dimitrov
Not my downvote - but, while this is correct, it doesn't really explain his current behavior of replacing the `"0"` but not the `" days"` portion...
Nick Craver
he wants to replace all the given words with a single empty character, or null, or simply remove them
Umair
@Nick, this behavior is inexplicable from what the OP provided as information. I gave a counter example for this.
Darin Dimitrov
@Darin - I concur, what he posted doesn't make any sense given the provided code, something outside the question going on here.
Nick Craver
+1  A: 

http://www.jsfiddle.net/jrJga/

works fine here..

Mikee