Search code examples
phpregexreplacetrim

Remove number then a space from the start of a string


How would I go about removing numbers and a space from the start of a string?

For example, from '13 Adam Court, Cannock' remove '13 '


Solution

  • Use the same regex I gave in my JavaScript answer, but apply it using preg_replace():

    preg_replace('/^\d+\s+/', '', $str);