This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
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.