【发布时间】:2021-01-24 07:14:37
【问题描述】:
我正在读取一个 .txt 文件,该文件已拆分为包含信息行的数组。
这是我原来的.txt
|datestamp |endpoint |id |
|2019-03-01 09:00:00UTC |/co.html |12345 |
|2019-03-01 09:00:00UTC |/co.html |12346 |
|2019-03-01 10:00:00UTC |/co.html |12345 |
|2019-03-01 10:30:00UTC |/hello.html |12347 |
|2019-03-01 11:00:00UTC |/co.html |12347 |
|2019-03-02 11:00:00UTC |/co.html |12348 |
|2019-03-02 12:00:00UTC |/hello.html |12348 |
|2019-03-03 13:00:00UTC |/hello.html |12349 |
所以现在我得到了这个信息数组:
[
'|datestamp |endpoint |id |',
'|2019-03-01 09:00:00UTC |/co.html |12345 |',
'|2019-03-01 09:00:00UTC |/co.html |12346 |',
'|2019-03-01 10:00:00UTC |/co.html |12345 |',
'|2019-03-01 10:30:00UTC |/hello.html |12347 |',
'|2019-03-01 11:00:00UTC |/co.html |12347 |',
'|2019-03-02 11:00:00UTC |/co.html |12348 |',
'|2019-03-02 12:00:00UTC |/hello.html |12348 |',
'|2019-03-03 13:00:00UTC |/hello.html |12349 |',
''
]
所以我需要过滤说这些日期戳 2019-03-01 10:00:00UTC - 2019-03-02 11:00:00UTC
我需要用松树“|”分割数组吗?在这样做之前呢?
我该如何解决这个问题?
【问题讨论】:
-
是的,用
|分割每一行。 -
感谢@IslamElshobokshy 的回复,虽然我也是这样,但后来 ADT 展示了另一个版本。
标签: javascript arrays filter date-range