Kirby tasks list

Made its own question topic, but am referring to this

I’m playing with it in order to extend it a bit more and add for example support for dates.

So far this is what I did, I add a date to my task like this:

- [ ] task d(20022018)

or

- [ ] task s(20022018)

and I have a new preg_replace function for convert it to d(20-02-2018)

$text = preg_replace('/([d|s]\()(\d{2})(\d{2})(\d{4}\))/', '$1$2-$3-$4', $text);

this works well so far (why I don’t bother adding dashes on the text file it’s another story). Now, I want to extend this

$text = preg_replace('/^\s*<li>\s*(<p>)?\s*\[x\]/mi', '<li style="list-style-type:none;">$1<input type="checkbox" disabled checked>', $text);

which converts a list item w/ - [x] to a checked input checkbox, to grab the converted date and add it as a date field as part of the list item.

The new preg_replace I put together works, but stops after the first match. Testing it on two different regex website gives different results (in one the regex matches all the lines, in the other only the first one). What am I missing?

$text = preg_replace('/^\s*<li>?\s*\[x\]\s*(.*?(\d{2})-(\d{2})-(\d{4})\))/mi', '<li date="$4-$3-$2" style="list-style-type:none;"><input type="checkbox" disabled checked>$1', $text);

Also, in the madness of working w/ regex, I ended up moving $1 after the input tag element (not clear why I had to do this, and why in the original regex it was put before the input tag).

Also, I’m a bit unsure if the first regex that only converts all dates can be included in an even more extended preg_replace for when converting task list items? Maybe better to keep it as simple as possible due to regex complexity? Curious how to clean up and write less code, while still having it clear enough.