Algorithm for transform timestamp range to Regular Expression or Wildcard Symbol.
go run get_regexp_between_timestamp.go
examples:
StartTime = 1546300800 EndTime = 1570675775
154630080[0123456789]
15463008[123456789][0123456789]
1546300[9][0123456789][0123456789]
154630[123456789][0123456789][0123456789][0123456789]
15463[123456789][0123456789][0123456789][0123456789][0123456789]
1546[456789][0123456789][0123456789][0123456789][0123456789][0123456789]
154[789][0123456789][0123456789][0123456789][0123456789][0123456789][0123456789]
15[56][0123456789][0123456789][0123456789][0123456789][0123456789][0123456789][0123456789]
1570[012345][0123456789][0123456789][0123456789][0123456789][0123456789]
15706[0123456][0123456789][0123456789][0123456789][0123456789]
157067[01234][0123456789][0123456789][0123456789]
1570675[0123456][0123456789][0123456789]
15706757[0123456][0123456789]
157067577[012345]
154630080[0-9]
15463008[1-9][0-9]
1546300[9-9][0-9][0-9]
154630[1-9][0-9][0-9][0-9]
15463[1-9][0-9][0-9][0-9][0-9]
1546[4-9][0-9][0-9][0-9][0-9][0-9]
154[7-9][0-9][0-9][0-9][0-9][0-9][0-9]
15[5-6][0-9][0-9][0-9][0-9][0-9][0-9][0-9]
1570[0-5][0-9][0-9][0-9][0-9][0-9]
15706[0-6][0-9][0-9][0-9][0-9]
157067[0-4][0-9][0-9][0-9]
1570675[0-6][0-9][0-9]
15706757[0-6][0-9]
157067577[0-5]
If GetBetweenString have the style params, then it can return regexp. For example:
GetBetweenString("0", "9") // return [0123456789]
GetBetweenString("0", "9", "-") // return [0-9]
It return a list, you can use list.join("|") to get regex.
一个可以将时间戳字符串范围转换为正则或通配符的算法
go run get_regexp_between_timestamp.go
例子:
StartTime = 1546300800 EndTime = 1570675775
154630080[0123456789]
15463008[123456789][0123456789]
1546300[9][0123456789][0123456789]
154630[123456789][0123456789][0123456789][0123456789]
15463[123456789][0123456789][0123456789][0123456789][0123456789]
1546[456789][0123456789][0123456789][0123456789][0123456789][0123456789]
154[789][0123456789][0123456789][0123456789][0123456789][0123456789][0123456789]
15[56][0123456789][0123456789][0123456789][0123456789][0123456789][0123456789][0123456789]
1570[012345][0123456789][0123456789][0123456789][0123456789][0123456789]
15706[0123456][0123456789][0123456789][0123456789][0123456789]
157067[01234][0123456789][0123456789][0123456789]
1570675[0123456][0123456789][0123456789]
15706757[0123456][0123456789]
157067577[012345]
154630080[0-9]
15463008[1-9][0-9]
1546300[9-9][0-9][0-9]
154630[1-9][0-9][0-9][0-9]
15463[1-9][0-9][0-9][0-9][0-9]
1546[4-9][0-9][0-9][0-9][0-9][0-9]
154[7-9][0-9][0-9][0-9][0-9][0-9][0-9]
15[5-6][0-9][0-9][0-9][0-9][0-9][0-9][0-9]
1570[0-5][0-9][0-9][0-9][0-9][0-9]
15706[0-6][0-9][0-9][0-9][0-9]
157067[0-4][0-9][0-9][0-9]
1570675[0-6][0-9][0-9]
15706757[0-6][0-9]
157067577[0-5]
在GetBetweenString中传第三个参数间隔符,如果传-则是正则,不传则是通配符。例如:
GetBetweenString("0", "9") // return [0123456789]
GetBetweenString("0", "9", "-") // return [0-9]
返回的是一个list,如果需要整合正则可以list.join("|")