A system message may include the following status sentence:
This function was executed 312 times, most often used by process Urbanus: 16.06.2012 14:10.
The sentence always is in one line.
I need to:
- Retrieve the three bold parts:
- An integer between 1 and n (here: 312)
- A string consisting of characters, symbols (incl. whitespaces but excl. newline) and numbers (here: Urbanus)
- A date which is either “Today” or “Yesterday” or a date in DD.MM.YYYY (here: 16.06.2012)
- A time in 24hrs hh:mm format (here: 14:10)
- Remove the whole sentence from the system message.
I tried the following, but it’s not working:
$matches = preg_replace(
"/This function was executed ([1-9]|[1-9][0-9]|[1-9][0-9][0-9]) times, most often used by process (.+?): ((Today|Yesterday|[0-9]{2}.[0-9]{2}.[0-9]{4}) ([0-9]{2}:[0-9]{2}))./iU",
"",
$message);
1part:
Try use
preg_match_all. Also I improve your pattern