J
jwcarlton
I have a section that may, or may not, include a whitespace. Like
this:
var string = "<b><p>Jason</p> </b>";
I'm wanting to do this:
string = string.replace(/<b><p>jason<\/p> <\/b>/gi, "Jason");
But the problem is that the whitespace between </p> and </b> might NOT
exist. I'm doing it like this, but I know that it's wrong because it
would find anything, not just a whitespace:
string = string.replace(/<b><p>jason<\/p>(.*)<\/b>/gi, "Jason");
I'm pretty sure that this isn't right, but it's the direction I was
going:
string = string.replace(/<b><p>jason<\/p>(\s*|(.)*?)<\/b>/gi,
"Jason");
What's the correct way to match a whitespace, or nothing?
this:
var string = "<b><p>Jason</p> </b>";
I'm wanting to do this:
string = string.replace(/<b><p>jason<\/p> <\/b>/gi, "Jason");
But the problem is that the whitespace between </p> and </b> might NOT
exist. I'm doing it like this, but I know that it's wrong because it
would find anything, not just a whitespace:
string = string.replace(/<b><p>jason<\/p>(.*)<\/b>/gi, "Jason");
I'm pretty sure that this isn't right, but it's the direction I was
going:
string = string.replace(/<b><p>jason<\/p>(\s*|(.)*?)<\/b>/gi,
"Jason");
What's the correct way to match a whitespace, or nothing?