Я пытаюсь установить сигнал тревоги в программном обеспечении погоды, чтобы посмотреть прогноз для моего района и сказать мне, появляется ли слово "серьезный" в предстоящем прогнозе. Я смотрю на следующий текстовый файл (немного сокращен):
000
FPUS55 KBOU 301529
ZFPBOU
Zone Forecast Product for Northeast Colorado
National Weather Service Denver/Boulder CO
929 AM MDT Sat Jun 30 2018
COZ042-044-010615-
Northeast Weld County-Morgan County-
including Briggsdale, Grover, Pawnee Buttes, Raymer, Stoneham,
Brush, Fort Morgan, Goodrich, and Wiggins
929 AM MDT Sat Jun 30 2018
.REST OF TODAY...Chance of thunderstorms early in the afternoon.
Thunderstorms likely late in the afternoon. Some thunderstorms
may be severe with large hail. Highs 68 to 74. Northeast winds 10
to 15 mph with gusts to around 25 mph. Chance of thunderstorms 70
percent.
.TONIGHT...Mostly cloudy with a 30 percent chance of
thunderstorms in the evening, then mostly clear after midnight.
Some thunderstorms may be severe. Lows near 50. North winds 10 to
15 mph with gusts to around 25 mph in the evening becoming light.
.SUNDAY...Mostly sunny. Warmer. Highs in the 80s.
.SUNDAY NIGHT...Mostly clear. Lows in the mid to upper 50s. South
winds 10 to 15 mph.
.MONDAY...Mostly sunny. Highs near 90.
.MONDAY NIGHT AND TUESDAY...Partly cloudy with a 10 percent
chance of thunderstorms. Lows near 60. Highs in the lower to mid
90s.
.TUESDAY NIGHT AND Independence Day...Partly cloudy. Lows near
60. Highs in the 90s.
.WEDNESDAY NIGHT AND THURSDAY...Partly cloudy with a 10 percent
chance of thunderstorms. Lows near 60. Highs in the lower to mid
90s.
.THURSDAY NIGHT...Partly cloudy with a 30 percent chance of
thunderstorms. Lows near 60.
.FRIDAY...Partly cloudy with a 10 percent chance of
thunderstorms. Highs in the lower to mid 90s.
$$
COZ048>051-010615-
Logan County-Washington County-Sedgwick County-Phillips County-
including Crook, Merino, Sterling, Peetz, Akron, Cope,
Last Chance, Otis, Julesburg, Ovid, Sedgwick, Amherst, Haxtun,
and Holyoke
929 AM MDT Sat Jun 30 2018
.REST OF TODAY...Chance of showers and slight chance of
thunderstorms early in the afternoon. Showers likely and chance
of thunderstorms late in the afternoon. Highs in the lower 70s.
North winds 10 to 20 mph. Chance of precipitation 60 percent.
.TONIGHT...Mostly cloudy with a 50 percent chance of
thunderstorms in the evening, then mostly clear after midnight.
Some thunderstorms may be severe. Lows in the lower to mid 50s.
North winds 10 to 15 mph with gusts to around 25 mph in the
evening becoming light.
.SUNDAY...Mostly sunny. Highs in the mid 80s.
.SUNDAY NIGHT...Mostly clear. Lows near 60. South winds 10 to
15 mph.
.MONDAY...Partly cloudy with a 10 percent chance of
thunderstorms. Highs in the lower 90s. South winds 10 to 15 mph.
.MONDAY NIGHT...Partly cloudy with a 10 percent chance of
thunderstorms. Lows near 60.
.TUESDAY...Partly cloudy. Highs in the mid 90s.
.TUESDAY NIGHT...Partly cloudy with a 10 percent chance of
thunderstorms. Lows in the lower to mid 60s.
.INDEPENDENCE DAY...Partly cloudy. Highs in the mid 90s.
.WEDNESDAY NIGHT...Partly cloudy with a 10 percent chance of
thunderstorms. Lows in the lower to mid 60s.
.THURSDAY...Partly cloudy with a chance of rain showers and
slight chance of thunderstorms. Highs in the lower 90s. Chance of
precipitation 30 percent.
.THURSDAY NIGHT...Partly cloudy with a 30 percent chance of
thunderstorms. Lows in the lower to mid 60s.
.FRIDAY...Partly cloudy. Highs in the lower 90s.
$$
COZ046-010615-
North and Northeast Elbert County Below 6000 Feet/North Lincoln
County-
including Agate, Hugo, Limon, and Matheson
929 AM MDT Sat Jun 30 2018
.REST OF TODAY...Mostly cloudy. Chance of rain showers and slight
chance of thunderstorms early in the afternoon. Chance of
thunderstorms late in the afternoon. Some thunderstorms may be
severe late in the afternoon. Highs in the mid 70s. North winds
15 to 25 mph. Chance of precipitation 40 percent.
.TONIGHT...Mostly cloudy with a 50 percent chance of
thunderstorms in the evening, then partly cloudy after midnight.
Lows around 50. North winds 10 to 20 mph in the evening becoming
light.
.SUNDAY...Mostly sunny. Highs in the lower 80s. South winds 10 to
15 mph in the afternoon.
.SUNDAY NIGHT...Partly cloudy with a 10 percent chance of
thunderstorms. Lows in the mid to upper 50s. South winds 10 to
15 mph.
.MONDAY...Partly cloudy with a 10 percent chance of
thunderstorms. Highs near 90. South winds 10 to 15 mph.
.MONDAY NIGHT...Partly cloudy with a 10 percent chance of
thunderstorms. Lows in the mid 50s to lower 60s.
.TUESDAY THROUGH INDEPENDENCE DAY...Partly cloudy. Highs in the
lower to mid 90s. Lows in the mid 50s to lower 60s.
.WEDNESDAY NIGHT...Mostly cloudy with a 20 percent chance of
thunderstorms. Lows near 60.
.THURSDAY...Partly cloudy with a 10 percent chance of
thunderstorms. Highs around 90.
.THURSDAY NIGHT...Partly cloudy with a 30 percent chance of
thunderstorms. Lows near 60.
.FRIDAY...Partly cloudy with a 10 percent chance of
thunderstorms. Highs in the upper 80s.
$$
Итак, я хочу заглянуть в группу округа Вашингтон, которая является вторым разделом вышеуказанного прогноза. Фраза «округ Вашингтон» всегда будет отображаться в заголовке раздела прогноза моей страны, а «$$» всегда будет заключать каждый раздел прогноза. В качестве примера я выяснил, что выражение RegEx
Washington County([\D\S]*?)\${2}
найдет весь текст в моей части прогноза. Затем, особенно в части прогноза моей страны, меня интересует период прогноза "TONIGHT". Я понял, что выражение RegEx
\.TONIGHT[\D\S]*?(?=\s\.)
найдет период прогноза "TONIGHT" для всех разделов прогноза. И, конечно же, выражение RegEx
severe
найдет все случаи "серьезного" по всему файлу. Когда у меня возникают проблемы, я пытаюсь собрать все три и получить результат только тогда, когда слово «серьезный» встречается в прогнозируемом периоде «TONIGHT» в разделе прогнозов «Washington County». Когда я пытаюсь сложить все это вместе, я обнаруживаю, что RegEx найдет слова, которые я ищу, но будет охватывать соседние разделы прогноза. Есть ли способ сделать этот единственный поиск между «округом Вашингтон» и следующим экземпляром «$$», чтобы быть уверенным, что я не перенаправлюсь в следующий раздел прогноза и не получу ложное срабатывание?
Большое спасибо всем, кто может мне помочь с этим. Я довольно новичок в RegEx, поэтому просто не знаю, как ограничить область поиска.