D
Dan Kohn
Could you please take a look at this regex (line 52) that's just
killing me. (It's at <http://rafb.net/paste/results/l4U66N90.html> or
below). When I split it up (lines 44-49) it works fine. There must be
something obvious but I can't see it.
doc = <<EOF
<Placemark>
<!--NOBBS-->
<name>KSFO</name>
<Point>
<coordinates>-122.374889,37.618972</coordinates>
</Point>
<LookAt>
<longitude>-122.374889</longitude>
<latitude>37.618972</latitude>
<range>100000.0</range>
</LookAt>
<styleUrl>#iata</styleUrl>
<description>
<![CDATA[<h3>San Francisco Intl,
Usa</h3><table><tr><td>ICAO:</td><td>KSFO</td></tr><tr><td>IATA:</td><td>SFO</td></tr><tr><td>Altitude:</td><td>
13
ft.</td></tr><tr><td>Type:</td><td>Civil</td></tr><tr><td>Rwy 19L/01R:</td><td>193.0°/13.0° 8648ft., Alt. 10.0ft.</td></tr><tr><td>Rwy 19R/01L:</td><td>193.0°/13.0° 7500ft., Alt. 8.8ft.</td></tr><tr><td>Rwy 28L/10R:</td><td>283.0°/103.0° 10602ft., Alt. 12.7ft.</td></tr><tr><td>Rwy 28R/10L:</td><td>283.0°/103.0° 11870ft., Alt. 13.1ft.</td></tr><tr><td>Timezone:</td><td>UTC-8(-7DT)</td></tr><tr><td>DAFIF Cycle:</td><td>200510</td></tr><tr><td></td><td></td></tr><tr><td>CAUTION</td><td>WIP
UFN apch end Rwy 28L/R and 19L. Bird haz. Rubber accumulated first
3000' Rwy28L and 28R. Pilots shall strictly flw nose-gear lines, no
oversteering adjustment perms. Several rwy hold posn signs on rgt side
of twy.</td></tr><tr><td>CG</td><td>Min 24 hr PPR exc CG msn,
C650-808-2901/2902 dur nml duty hr 1600-2400Z++. Svc ltd to prk, ramp
space only, C-12/C-20 or smaller. No fuel, messing, space A svc,govt
sfc transportation, tran qtrs, maint. 15 min before arr ctc SAN FRAN
AIR
3</td></tr><tr><td>CG</td><td>81.8.</td></tr><tr><td>FUEL</td><td>(NC-100,
100LL, A)</td></tr><tr><td>LGT</td><td>Rwy 19L SALSF are only 1100'
long with only one flasher on the last lgt
stn.</td></tr><tr><td>MISC</td><td>Rwy 01R-19L, 10R-28L, 10L-28R
grooved exc at rwy int. Rwy 01L-19R grooved exc atrwy int and 535' N of
Twy C. Hi speed Twy T grooved btn Rwy 28R and 28L. Copterldg area mrk
on Twy C in front of Coast Guard OPS for mil use only. Rwy 10
pref</td></tr><tr><td>MISC</td><td>rwy 0900-1400Z++, wx and cond perms.
Flt Notification Svc, ADCUS, avbl.
LLWAS.</td></tr><tr><td>NS ABTMT</td><td>For pro fone
C650-821-5100, 1600-0100Z++ Mon-Fri.</td></tr><tr><td>RSTD</td><td>Taxi
speed less than 10 Kt per hr on non-rstd twy trml side of rwy int, less
than 5 Kt per hr when B747-400 pass on Twy A or
B.</td></tr><tr><td>TFC PAT</td><td>Rgt tfc Rwy 10R,
28R.</td></tr></table>]]>
</description>
<Snippet>
<![CDATA[San Francisco Intl (SFO)]]>
</Snippet>
</Placemark>
<Placemark>
<!--NOBBS-->
<name>PHOG</name>
<Point>
<coordinates>-156.430458,20.898650</coordinates>
</Point>
<LookAt>
<longitude>-156.430458</longitude>
<latitude>20.898650</latitude>
<range>100000.0</range>
</LookAt>
<styleUrl>#iata</styleUrl>
<description>
<![CDATA[<h3>Kahului, Usa Maui
Isl.</h3><table><tr><td>ICAO:</td><td>PHOG</td></tr><tr><td>IATA:</td><td>OGG</td></tr><tr><td>Altitude:</td><td>
54
ft.</td></tr><tr><td>Type:</td><td>Civil</td></tr><tr><td>Rwy 20/02:</td><td>205.0°/25.0° 6995ft., Alt. 12.4ft.</td></tr><tr><td>Rwy 23/05:</td><td>235.0°/55.0° 4990ft., Alt. 15.9ft.</td></tr><tr><td>Island/Group:</td><td>Maui
I</td></tr><tr><td>Timezone:</td><td>UTC-10</td></tr><tr><td>DAFIF Cycle:</td><td>200505</td></tr><tr><td></td><td></td></tr><tr><td>CAUTION</td><td>Lgtd
twr 570' hi 3 NM W of arpt. Bird haz. Due to non-vis twr unable to
determine if the flw areas are clear of obst/tfc; portion of Twy F btn
commuter trml andapch end Rwy 05. Due to non-vis twr unable to provide
svc btn acft/veh on commu</td></tr><tr><td>CAUTION</td><td>ter trml S
of Twy F and copter trml E of apch end Rwy 02. 130' crane 6000' SW apch
end Rwy 02.</td></tr><tr><td>FUEL</td><td>A+ (Air Service Hawaii,
1700-0400Z, C808-871-5572; OT 1.5 hr PN rqr, C808-870-8007
C808-757-0321, $100 fee.) (NC-100-Avbl 24 hr
self-svc).</td></tr><tr><td>LGT</td><td>When twr is unattended,
ACTIVATE-MALSR Rwy 02, HIRL Rwy 02-20 and MIRL Rwy 05-23-CTAF. VASI Rwy
02 TCH 65', Rwy 20 TCH 76', Rwy 05 TCH 40'. VASI Rwy 05 unuse byd 4 NM
due rising terrain.</td></tr><tr><td>MISC</td><td>Crash and fire eqpt
avbl 24 hr. All rwy grooved. LLWAS 0000-0900Z. LAWRS
1600-0900Z.</td></tr><tr><td>NS ABTMT</td><td>See ARR/DEP GRAPHICS
Sec E.</td></tr><tr><td>RSTD</td><td>24 hr PPR for Class A and B
explosives and 4 hr PPR for other haz cargo in/out of arpt, fone
C808-872-3830 1745-0230Z, OT C808-872-3888. Portions of commuter and
scenic flt opr not vis fr twr. Commuter trml ramp rstd to acft 140,000
lb or l</td></tr><tr><td>RSTD</td><td>ess. Mil copter opr rstd to haz
material area N Rwy 05-23. Area E of apch end Rwy 02 designated as
copter opr area. No F/W acft may opr on helipad. PPR for F/W opr on
helipad C808-872-3880 1515-0800Z. Access to helipad fr Twy C only. Ramp
a</td></tr><tr><td>RSTD</td><td>rea E side of Rwy 02 under state auth.
FAA not responsible for drct and ctl of gnd tfc in area. Tran prk lctd
on NE sec of E ramp.</td></tr></table>]]>
</description>
<Snippet>
<![CDATA[Kahului (OGG)]]>
</Snippet>
</Placemark>
EOF
doc.scan(/<Placemark>(.*?)<\/Placemark>/m) { |e|
s = e.to_s
s =~ /<longitude>(.*?)<\/longitude>/m
long = $1
s =~ /<latitude>(.*?)<\/latitude>/m
lat = $1
s =~ /IATA:.*?([A-Z0-9]{3})[^A-Z0-9]/m
code = $1
p "line: " + long + ":" + lat + ":" + code
s.match( /<longitude>(.*?)<\/longitude>.*?
<latitude>(.*?)<\/latitude>.*?
IATA:.*?([A-Z0-9]{3})[^A-Z0-9]/mx
) { |match|
p "match: " + $1 + ":" + $2 + ":" + $3
}
}
killing me. (It's at <http://rafb.net/paste/results/l4U66N90.html> or
below). When I split it up (lines 44-49) it works fine. There must be
something obvious but I can't see it.
doc = <<EOF
<Placemark>
<!--NOBBS-->
<name>KSFO</name>
<Point>
<coordinates>-122.374889,37.618972</coordinates>
</Point>
<LookAt>
<longitude>-122.374889</longitude>
<latitude>37.618972</latitude>
<range>100000.0</range>
</LookAt>
<styleUrl>#iata</styleUrl>
<description>
<![CDATA[<h3>San Francisco Intl,
Usa</h3><table><tr><td>ICAO:</td><td>KSFO</td></tr><tr><td>IATA:</td><td>SFO</td></tr><tr><td>Altitude:</td><td>
13
ft.</td></tr><tr><td>Type:</td><td>Civil</td></tr><tr><td>Rwy 19L/01R:</td><td>193.0°/13.0° 8648ft., Alt. 10.0ft.</td></tr><tr><td>Rwy 19R/01L:</td><td>193.0°/13.0° 7500ft., Alt. 8.8ft.</td></tr><tr><td>Rwy 28L/10R:</td><td>283.0°/103.0° 10602ft., Alt. 12.7ft.</td></tr><tr><td>Rwy 28R/10L:</td><td>283.0°/103.0° 11870ft., Alt. 13.1ft.</td></tr><tr><td>Timezone:</td><td>UTC-8(-7DT)</td></tr><tr><td>DAFIF Cycle:</td><td>200510</td></tr><tr><td></td><td></td></tr><tr><td>CAUTION</td><td>WIP
UFN apch end Rwy 28L/R and 19L. Bird haz. Rubber accumulated first
3000' Rwy28L and 28R. Pilots shall strictly flw nose-gear lines, no
oversteering adjustment perms. Several rwy hold posn signs on rgt side
of twy.</td></tr><tr><td>CG</td><td>Min 24 hr PPR exc CG msn,
C650-808-2901/2902 dur nml duty hr 1600-2400Z++. Svc ltd to prk, ramp
space only, C-12/C-20 or smaller. No fuel, messing, space A svc,govt
sfc transportation, tran qtrs, maint. 15 min before arr ctc SAN FRAN
AIR
3</td></tr><tr><td>CG</td><td>81.8.</td></tr><tr><td>FUEL</td><td>(NC-100,
100LL, A)</td></tr><tr><td>LGT</td><td>Rwy 19L SALSF are only 1100'
long with only one flasher on the last lgt
stn.</td></tr><tr><td>MISC</td><td>Rwy 01R-19L, 10R-28L, 10L-28R
grooved exc at rwy int. Rwy 01L-19R grooved exc atrwy int and 535' N of
Twy C. Hi speed Twy T grooved btn Rwy 28R and 28L. Copterldg area mrk
on Twy C in front of Coast Guard OPS for mil use only. Rwy 10
pref</td></tr><tr><td>MISC</td><td>rwy 0900-1400Z++, wx and cond perms.
Flt Notification Svc, ADCUS, avbl.
LLWAS.</td></tr><tr><td>NS ABTMT</td><td>For pro fone
C650-821-5100, 1600-0100Z++ Mon-Fri.</td></tr><tr><td>RSTD</td><td>Taxi
speed less than 10 Kt per hr on non-rstd twy trml side of rwy int, less
than 5 Kt per hr when B747-400 pass on Twy A or
B.</td></tr><tr><td>TFC PAT</td><td>Rgt tfc Rwy 10R,
28R.</td></tr></table>]]>
</description>
<Snippet>
<![CDATA[San Francisco Intl (SFO)]]>
</Snippet>
</Placemark>
<Placemark>
<!--NOBBS-->
<name>PHOG</name>
<Point>
<coordinates>-156.430458,20.898650</coordinates>
</Point>
<LookAt>
<longitude>-156.430458</longitude>
<latitude>20.898650</latitude>
<range>100000.0</range>
</LookAt>
<styleUrl>#iata</styleUrl>
<description>
<![CDATA[<h3>Kahului, Usa Maui
Isl.</h3><table><tr><td>ICAO:</td><td>PHOG</td></tr><tr><td>IATA:</td><td>OGG</td></tr><tr><td>Altitude:</td><td>
54
ft.</td></tr><tr><td>Type:</td><td>Civil</td></tr><tr><td>Rwy 20/02:</td><td>205.0°/25.0° 6995ft., Alt. 12.4ft.</td></tr><tr><td>Rwy 23/05:</td><td>235.0°/55.0° 4990ft., Alt. 15.9ft.</td></tr><tr><td>Island/Group:</td><td>Maui
I</td></tr><tr><td>Timezone:</td><td>UTC-10</td></tr><tr><td>DAFIF Cycle:</td><td>200505</td></tr><tr><td></td><td></td></tr><tr><td>CAUTION</td><td>Lgtd
twr 570' hi 3 NM W of arpt. Bird haz. Due to non-vis twr unable to
determine if the flw areas are clear of obst/tfc; portion of Twy F btn
commuter trml andapch end Rwy 05. Due to non-vis twr unable to provide
svc btn acft/veh on commu</td></tr><tr><td>CAUTION</td><td>ter trml S
of Twy F and copter trml E of apch end Rwy 02. 130' crane 6000' SW apch
end Rwy 02.</td></tr><tr><td>FUEL</td><td>A+ (Air Service Hawaii,
1700-0400Z, C808-871-5572; OT 1.5 hr PN rqr, C808-870-8007
C808-757-0321, $100 fee.) (NC-100-Avbl 24 hr
self-svc).</td></tr><tr><td>LGT</td><td>When twr is unattended,
ACTIVATE-MALSR Rwy 02, HIRL Rwy 02-20 and MIRL Rwy 05-23-CTAF. VASI Rwy
02 TCH 65', Rwy 20 TCH 76', Rwy 05 TCH 40'. VASI Rwy 05 unuse byd 4 NM
due rising terrain.</td></tr><tr><td>MISC</td><td>Crash and fire eqpt
avbl 24 hr. All rwy grooved. LLWAS 0000-0900Z. LAWRS
1600-0900Z.</td></tr><tr><td>NS ABTMT</td><td>See ARR/DEP GRAPHICS
Sec E.</td></tr><tr><td>RSTD</td><td>24 hr PPR for Class A and B
explosives and 4 hr PPR for other haz cargo in/out of arpt, fone
C808-872-3830 1745-0230Z, OT C808-872-3888. Portions of commuter and
scenic flt opr not vis fr twr. Commuter trml ramp rstd to acft 140,000
lb or l</td></tr><tr><td>RSTD</td><td>ess. Mil copter opr rstd to haz
material area N Rwy 05-23. Area E of apch end Rwy 02 designated as
copter opr area. No F/W acft may opr on helipad. PPR for F/W opr on
helipad C808-872-3880 1515-0800Z. Access to helipad fr Twy C only. Ramp
a</td></tr><tr><td>RSTD</td><td>rea E side of Rwy 02 under state auth.
FAA not responsible for drct and ctl of gnd tfc in area. Tran prk lctd
on NE sec of E ramp.</td></tr></table>]]>
</description>
<Snippet>
<![CDATA[Kahului (OGG)]]>
</Snippet>
</Placemark>
EOF
doc.scan(/<Placemark>(.*?)<\/Placemark>/m) { |e|
s = e.to_s
s =~ /<longitude>(.*?)<\/longitude>/m
long = $1
s =~ /<latitude>(.*?)<\/latitude>/m
lat = $1
s =~ /IATA:.*?([A-Z0-9]{3})[^A-Z0-9]/m
code = $1
p "line: " + long + ":" + lat + ":" + code
s.match( /<longitude>(.*?)<\/longitude>.*?
<latitude>(.*?)<\/latitude>.*?
IATA:.*?([A-Z0-9]{3})[^A-Z0-9]/mx
) { |match|
p "match: " + $1 + ":" + $2 + ":" + $3
}
}