php - regExp to cover the entire range of hours

enter image description here

I need my regexp to cover every hour range that is below.

07:00 - 15:30
16:00 bis 20:30
7:00-15:00
7.00 Uhr 16.30 Uhr
7 - 16.30 Uhr
7 - 16 Uhr
7:30 - 16 Uhr
7:15 Uhr bis 16:30 Uhr
7-16.15 Uhr

I need regExp to cover the entire range of hours, each of the following and nothing else

I have a regExp

([0-9] | [01]? [0-9] | 2 [0-3]) ((: |. |.) ([0-5] [0-9])?) ( . *?) ([0-9] | [01]? [0-9] | 2 [0-3]) ((: |. |.) ([0-5] [0-9])?)

but it doesn't work as much as I would like it to

7:00-15 instead 7:00-15:00 7.00 Uhr 16 instead 7.00 Uhr 16.30 Uhr

Answer

Solution:

This regular expression matches all the entries you listed:

^(?<start>(?<starthour>[0-9]+)(?:[:\.](?<startminute>[0-9]+))?)(?:[\s]*(?:[-??�]|bis|Uhr)[\s]*)*(?<end>(?<endhour>[0-9]+)(?:[:\.](?<endminute>[0-9]+))?)(?:[\s]*(?:Uhr)[\s]*)?$

https://regex101.com/r/48i2aZ/2

I left out capturing "Uhr" and "bis" - I don't speak German but I assume they mean something like hour or between the hours of.

Source