Regex in php, select everything after part

I have a line where I only want content after '### -'.

Example:

1234 - This is a string with 100 characters

      

I want to get this: This is a string with 100 characters

I've been trying to get this for hours, but I can't seem to get it to work. I realized that this code chose numbers and sign:, #^\d+ - #

but I need the complete opposite part of the string.

Help evaluate

+3


source to share


1 answer


You can use this regex:

~^\d+ - (.+)$~

      

And capture captured group # 1

Or using the reset match \K

:



~^\d+ - \K.+$~

      

Demo version of RegEx

PS: You can also use your programmed regex in preg_replace

like this:

$input = preg_replace('#^\d+ - #', '', $input);

      

+4


source







All Articles