#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    8
    Rep Power
    0

    Unhappy Finding a full paragraph that starts with....


    Hello group.
    I'm trying to find a full paragraph that starts with the words "FORECAST VALID" OR "OUTLOOK VALID" in the below text...

    I've tried the following, but it puts the last 2 OUTLOOK VALID paragraphs as one match... where I would like to match separately.
    (FORECAST|OUTLOOK)\s*VALID[^\n]*\n[^\n]*\n[^\n]*\n[^\n]*\n[^\n\^\n]*

    Code:
    ZCZC MIATCMEP2 ALL
    TTAA00 KNHC DDHHMM
     
    TROPICAL STORM GIL FORECAST/ADVISORY NUMBER   3
    NWS NATIONAL HURRICANE CENTER MIAMI FL       EP072013
    0300 UTC WED JUL 31 2013
     
    THERE ARE NO COASTAL WATCHES OR WARNINGS IN EFFECT.
     
    TROPICAL STORM CENTER LOCATED NEAR 13.1N 117.6W AT 31/0300Z
    POSITION ACCURATE WITHIN  20 NM
     
    PRESENT MOVEMENT TOWARD THE WEST-NORTHWEST OR 285 DEGREES AT  13 KT
     
    ESTIMATED MINIMUM CENTRAL PRESSURE 1002 MB
    MAX SUSTAINED WINDS  40 KT WITH GUSTS TO  50 KT.
    34 KT....... 30NE  20SE   0SW  30NW.
    12 FT SEAS.. 45NE   0SE  20SW  30NW.
    
    WINDS AND SEAS VARY GREATLY IN EACH QUADRANT.  RADII IN NAUTICAL
    MILES ARE THE LARGEST RADII EXPECTED ANYWHERE IN THAT QUADRANT.
     
    REPEAT...CENTER LOCATED NEAR 13.1N 117.6W AT 31/0300Z
    AT 31/0000Z CENTER WAS LOCATED NEAR 12.9N 117.0W
     
    FORECAST VALID 31/1200Z 13.6N 119.3W
    MAX WIND  50 KT...GUSTS  60 KT.
    50 KT... 20NE   0SE   0SW  20NW.
    34 KT... 40NE  30SE  20SW  40NW.
     
    FORECAST VALID 01/0000Z 14.2N 121.5W
    MAX WIND  55 KT...GUSTS  65 KT.
    64 KT... 10NE  30SE  10SW  10NW.
    50 KT... 20NE  20SE   0SW  20NW.
    34 KT... 50NE  40SE  30SW  50NW.
     
    FORECAST VALID 01/1200Z 14.7N 123.5W
    MAX WIND  60 KT...GUSTS  75 KT.
    50 KT... 30NE  20SE  20SW  30NW.
    34 KT... 60NE  50SE  40SW  60NW.
     
    FORECAST VALID 02/0000Z 15.2N 125.5W
    MAX WIND  65 KT...GUSTS  80 KT.
    50 KT... 40NE  30SE  20SW  40NW.
    34 KT... 70NE  60SE  50SW  70NW.
     
    FORECAST VALID 03/0000Z 15.9N 128.8W
    MAX WIND  65 KT...GUSTS  80 KT.
    50 KT... 40NE  30SE  20SW  40NW.
    34 KT... 70NE  60SE  50SW  70NW.
     
    EXTENDED OUTLOOK. NOTE...ERRORS FOR TRACK HAVE AVERAGED NEAR 150 NM
    ON DAY 4 AND 175 NM ON DAY 5...AND FOR INTENSITY NEAR 15 KT EACH DAY
     
    OUTLOOK VALID 04/0000Z 16.4N 132.0W
    MAX WIND  55 KT...GUSTS  65 KT.
     
    OUTLOOK VALID 05/0000Z 16.5N 135.5W
    MAX WIND  45 KT...GUSTS  55 KT.
     
    REQUEST FOR 3 HOURLY SHIP REPORTS WITHIN 300 MILES OF 13.1N 117.6W
     
    NEXT ADVISORY AT 31/0900Z
     
    $$
    FORECASTER STEWART
     
     
    NNNN
  2. #2
  3. Come play with me!
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,749
    Rep Power
    9397
    Be more specific with your regex, and make part of it optional (as the OUTLOOK VALID doesn't have wind speeds).
    Code:
    /(FORECAST|OUTLOOK) VALID.*\nMAX WIND.*(\n\d+ KT.*)*/i
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    8
    Rep Power
    0
    Originally Posted by requinix
    Be more specific with your regex, and make part of it optional (as the OUTLOOK VALID doesn't have wind speeds).
    Code:
    /(FORECAST|OUTLOOK) VALID.*\nMAX WIND.*(\n\d+ KT.*)*/i
    Thanks for your help... there may be some differences with the regex we are using but your approach led me to the answer than works for my compiler.

    Code:
    (FORECAST|OUTLOOK)\s+VALID.*\r\nMAX\s+WIND.*\r\n(\d+\s+KT.*\r\n)*
    Thanks again for your help.
    Regards,
    Bryan

IMN logo majestic logo threadwatch logo seochat tools logo