php - Why isn't my simple regex working? -
i have list of steps, , being echo
'd view li
items in ol
.
so, need remove leading numbers (that ol { list-style: decimal }
.
here example array member
- combine 1 tbs oil...
i tried regex
/^\d+\.\s*/
however, didn't remove 1.
in example above
but, when remove start of line anchor (^
), works.
here complete code.
foreach($method &$step) { $step = trim(preg_replace('/^\d+\.\s*/', '', $step)); var_dump($step); // quoted above }
what doing wrong?
thanks!
update
sorry guys, here var_dump()
of 1 of lines..
string(43) "4. remove heat , cover keep warm."
to me, doesn't there before digit.
is there whitespace before digit?
try
/^\s*\d+\.\s*/
Comments
Post a Comment