Ralph Heerich Ralph Heerich - 1 year ago 156
Python Question

regex for 24h unix timestamp

I would like to create a regex for a 24h unix timestamp starting from, say:

01/01/2015 00:00:00 **(1420066800)** to 01/01/2015 23:59:59 **(1420153199)**
, which is a difference of 86399 sec. in the unix time stamp format.

I'm using the
python lib, but it's buggy for such a huge ranges. The
method (
range_to_pattern(1420066800, 1420153199)
) would produce a regex of:

This is fine for the static bounds to create the regex, but when it comes to values like:
since the 7 digit (9) from the left is not in the third range group ([3-6]).

Can someone provide a better python3 lib or a workaround on how to create a regex for 86400 sec. of a day?

Answer Source

As per my comment above, you are using the wrong function from that library.

You should use the following:

range_to_regex(1420066800, 1420153199)

This returns the correct regex:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download