
May 10th, 2012, 01:45 PM
|
|
|
|
JavaScript - Remove text between [" "]
Hi
I will have to process chunks of text which may contain ["text between square brackets and double quotes"]. The idea is to remove that text, including the quotes and brackets, and keeping the rest.
My current regex is as follows:
/\["[^"]*"\]/g
This works fine on the following:
Hello ["remove this"] world ["remove this too"] !
Resulting in:
Hello world !
But it falls apart when I enter a quote inside [" "]:
Hello ["remo"ve this"] world ["remove this too"] !
In this case, the second [" "] is handles properly, but the first one stays put. What am I doing wrong?
Thanks
N6
|