btw: i know that using regex is not the best idea in the world...
For example i have such input variants:
<p> </p>
or
<p> </p>
or
<p> </p>
and i want to check my input like: all except <p>
with
in every amount of them (0, 1 or 50)...
i wrote such expression:
/[^<p>(\s* \s*)*<\/p>]/ig
and seems that it works, but!
for example i have such input:
<p> t </p>
or
<p> tttt tttt</p>
and it is thinking, that it is equal to my regex...
not a good idea...
what i do wrong in my regex? or maybe there are some better ways of solving this?
The FILTER function in Excel is used to filter a range of data based on the criteria that you specify. The function belongs to the category of Dynamic Arrays functions. The result is an array of values that automatically spills into a range of cells, starting from the cell where you enter a formula.
The FILTER function takes three arguments: array, include, and if_empty. Array is the range or array to filter. The include argument should consist of one or more logical tests. These tests should return TRUE or FALSE based on the evaluation of values from array.
Assuming you want to eliminate all <P>'s
with only nbsp;
(or more) inside them : then :
Assuming you have this
var a='a<p> </p>c<p> </p>d<p> aa </p>e';
And assuming the yellow part has to go : becuase it contains aa
inside :
You'll be left with all except the problematic P with pure nbsps :
Then this code :
a=a.replace(/(<p>.*?<\/p>)/g, function(match, p1 ) {
if (/^<p>(\s* \s*)*<\/p>$/ig.test(p1))
return '';
else return p1;
})
Will yield :
acd<p> aa </p>e
As you can see - the P
tag wasn't removed because of aa
http://jsbin.com/cizidayeru/3/edit
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With