-1

Is there a way to use the found occurrence within pattern? i.e.

$string='number23 cat99 dog23 car66';

for example, i want to find words that has number 23.... this doesnt work:

preg_match('/number(\d{2}) (.*?)%1/si', $string,  $new);
T.Todua
  • 49,021
  • 18
  • 212
  • 206

1 Answers1

0

Not sure I well understand your need, but how about using preg_match_all:

preg_match_all('/([a-z]+23)\b/i', $string, $matches);

This will match number23 and dog23

Toto
  • 86,179
  • 61
  • 85
  • 118