Hi all!
I am dealing with a string that can appear several different ways. I am basically looking for a string that either contains, one line of location coordinates, several lines of location coordinates, or no lines of location coordinates. An example of a location coordinate is this: "25NE 0SE 0SW 25NW". The area that I need to search in will occur after the words "MAX SUSTAINED WINDS" and before the word "REPEAT". Here are some examples of what I am talking about:
Here is the possibility with no location coordinates:
MAX SUSTAINED WINDS 65 KT WITH GUSTS TO 80 KT.
REPEAT...CENTER LOCATED NEAR 17.0N 77.5W AT 11/2100Z
Here is the possibility with one location coordinate:
MAX SUSTAINED WINDS 65 KT WITH GUSTS TO 80 KT.
64 KT....... 25NE 0SE 0SW 25NW.
REPEAT...CENTER LOCATED NEAR 17.0N 77.5W AT 11/2100Z
Here is the possibility with more than one location coordinate:
MAX SUSTAINED WINDS 65 KT WITH GUSTS TO 80 KT.
64 KT....... 25NE 0SE 0SW 25NW.
50 KT....... 40NE 0SE 0SW 40NW.
34 KT.......100NE 75SE 0SW 75NW.
12 FT SEAS..175NE 100SE 50SW 175NW.
REPEAT...CENTER LOCATED NEAR 17.0N 77.5W AT 11/2100Z
I know how to figure out if there are no location coordinates, or one location coordinate, but if there are more than one location coordinates, how can I capture each one into a string value. So, in the example above I would want something like this:
$string1 = "25NE 0SE 0SW 25NW"
$string2 = "40NE 0SE 0SW 40NW"
$string3 = "100NE 75SE 0SW 75NW"
$string4 = "175NE 100SE 50SW 175NW"
I am trying to do this just with regex. I prefer not to start splitting the string into array values and working on it that way.
Many thanks for any advise!!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.