S
Shandy Nantz
I am trying to parse out some characters from a string and I am having
some trouble because the string may have a space or it may not.
Basically I have a string that looks like this:
Seattle, WA[SEA] or
Colorado Springs, CO[COS] or
Denver, CO[DEN]
What I have so far to match the Seattle and Denver strings looks like
this:
/[A-Z]{1,1}[a-z]+[,]\s[A-Z]+\[{1,1}/
This regular expression is trying to grab everything within the []; in
the cases above this would be SEA, COS, DEN.
How do I make that same match if the initial string has whitespace
include, such as the Colorado Springs. I could add a \w, but what if the
section of string before the "," has more then one space; what if it has
three, or four, or ten.
If there is a better way to do this I all ears, regular expressions
isn't my cup of tea. Thanks,
-S
some trouble because the string may have a space or it may not.
Basically I have a string that looks like this:
Seattle, WA[SEA] or
Colorado Springs, CO[COS] or
Denver, CO[DEN]
What I have so far to match the Seattle and Denver strings looks like
this:
/[A-Z]{1,1}[a-z]+[,]\s[A-Z]+\[{1,1}/
This regular expression is trying to grab everything within the []; in
the cases above this would be SEA, COS, DEN.
How do I make that same match if the initial string has whitespace
include, such as the Colorado Springs. I could add a \w, but what if the
section of string before the "," has more then one space; what if it has
three, or four, or ten.
If there is a better way to do this I all ears, regular expressions
isn't my cup of tea. Thanks,
-S