0

I am trying to create a regular expression for some pattern matching that will match values to a specific pattern range. The range is time based and looks like:

start_time = 162950
end_time = 162959

So any integer greater than or equal 162950 or less than or equal to 162959 would match to the pattern. Would something like the following work ?

import re
`PATTERN = re.compile("("+start_time+"[0-9]{0}|"+end_time+")$")` 

If not, what do I need to do to match values inside the above range?

halfer
  • 19,824
  • 17
  • 99
  • 186
Stacey
  • 4,825
  • 17
  • 58
  • 99
  • 3
    searching for items in a range of numbers is not something regex is good for. Instead, why not do it in two steps? Get all start/end times, and then filter out the ones that are not in a range. – Bryan Oakley Jan 23 '18 at 22:12
  • 1
    seems like a simple if statement would work here. – JoshKisb Jan 23 '18 at 22:14

0 Answers0