Regular Expressions are completely new to me and having done much searching my expression for testing purposes is this:
preg_replace('/0.00%/','- ', '0.00%')
It yields 0.00%
when what I want is -
.
With preg_replace('/0.00%/','- ', '50.00%')
yields 50.00%
which is what I want - so this is fine.
But clearly the expression is not working as it is not, in the first example replacing 0.00%
with -
.
I can think of workarounds with if(){}
for testing length/content of string but presume the replace will be most efficient
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…