Regex for single digit catches two digit numbers?

2

This regex catches two digit nubers:

if I have y11 it will still catch it, how to match only y0, y1, y2, y3, y4, y5, y6, y7, y8, y9 ?? After the digit there might be a blank space or a letter or a dot.

preg_replace('/y([1-9]{1})/', 'y0$1', $string)
Share
Improve this question
1
  • [1-9] will not catch 0 though – brombeer Apr 5 at 10:44

Comments

Popular posts from this blog

Meaning of `{}` for return expression

Get current scroll position of ScrollView in React Native

flutter websocket connection issue