Reputation: 3584
I have a string in which I only want the content after '### - '.
Example:
1234 - This is a string with 100 characters
I want to get this out of it: This is a string with 100 characters
I've been trying to get this for a few hours now, but I can't get it to work. I figured this code selected the numbers and the - sign: #^\d+ - #
but I want the exact opposite part of the string.
Help is appreciated
Upvotes: 3
Views: 94
Reputation: 786011
You can use this regex:
~^\d+ - (.+)$~
And grab captured group #1
Or using match reset \K
:
~^\d+ - \K.+$~
PS: You can also use your attempted regex in preg_replace
like this:
$input = preg_replace('#^\d+ - #', '', $input);
Upvotes: 4