[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 20050728: LDM EREs



Brian,

> To: address@hidden
> From: Brian Olsen <address@hidden>
> Subject: LDM EREs
> Organization: MesoWest
> Keywords: 200507282209.j6SM9ljo002401

The above message contained the following:

> The LDM on my machine currently has the two following pqact entries...
> 
> WMO     ^S[AP](US|XX|CN|AK|HW|MX).. (....) ([0-3][0-9])([0-2][0-9])(..)
>         PIPE    -close  /usr/local/ldm/mesowest/process/metar2db_wmo2_qc_yesdb
>         /usr/local/ldm/mesowest/tmp/metar
>         /usr/local/ldm/mesowest/data/sfstns_nws.tbl
>         %y %m
> US|XX|CN|AK|HW|MX
> ... and ...
> 
> WMO     ^NZUS(07) KPQR ([0-3][0-9])([0-2][0-9])
>         PIPE    -close  /usr/local/ldm/mesowest/process/metar2db_wmo2_qc_yesdb
>         /usr/local/ldm/mesowest/tmp/metar
>         /usr/local/ldm/mesowest/data/sfstns_nws.tbl
>         %y %m
> 
> ...that I would like to combine.  The action for both is identical.
> Since the action is not referencing to any substring, my first
> inclination was to replace the parentheses with square brackets.  I
> soon learned this would not work.  How can I have "or" logic without
> using parentheses?  In the end, I would like to have something like:
>
> WMO ^[[NZUS07]|[[SA|SP][US|XX|CN|AK|HW|MX]..]] ....
[0-3][0-9][0-2][0-9]..
>
> ...but of course, this is wrong.

First, since there are no string substitution backreferences, the ERE-s can
be simplified by removed unnecessary parentheses:

WMO     ^S[AP](US|XX|CN|AK|HW|MX).. .... [0-3][0-9][0-2][0-9]..

WMO     ^NZUS07 KPQR [0-3][0-9][0-2][0-9]

Then, the simplest thing to do is to group the individual ERE-s using the 
grouping operator, "()", and then use the alternation operator, "|", i.e.,

WMO     (^S[AP](US|XX|CN|AK|HW|MX).. .... [0-3][0-9][0-2][0-9]..)|(^NZUS07 KPQR 
[0-3][0-9][0-2][0-9])

The beginning-of-string metacharacter can be "pulled out":

WMO     ^((S[AP](US|XX|CN|AK|HW|MX).. .... [0-3][0-9][0-2][0-9]..)|(NZUS07 KPQR 
[0-3][0-9][0-2][0-9]))

If the day-of-month and hour string always has two characters after it, then
the above can be further compressed to

WMO     ^((S[AP](US|XX|CN|AK|HW|MX).. .... )|(^NZUS07 KPQR 
))[0-3][0-9][0-2][0-9]..

Good luck.

> --Brian Olsen
> MesoWest

Regards,
Steve Emmerson

> NOTE: All email exchanges with Unidata User Support are recorded in the
> Unidata inquiry tracking system and then made publicly available
> through the web.  If you do not want to have your interactions made
> available in this way, you must let us know in each email you send to us.


NOTE: All email exchanges with Unidata User Support are recorded in the Unidata inquiry tracking system and then made publicly available through the web. If you do not want to have your interactions made available in this way, you must let us know in each email you send to us.