
mungedout
Novice
Jul 2, 2005, 2:18 PM
Post #1 of 6
(1752 views)
|
|
REGEX - screen strings, separate values, escaped chars
|
Can't Post
|
|
I have a database with info (1=item) followed by OPTIONAL secondary info (2=size) as a single value: @clothing = ("Fun-Stuff (MED)", "Skirts_Pants (LARGE)", "Ski Masks", "Blouse's (SMALL)", "Ties", "Jeans (10/12)",); I need to screen and separate the values. The only "good" data will contain alphanumeric characters, the asterisk, apostrophe, hyphen, underscore, or a period (*._-') in the first group, followed by an OPTIONAL single set of parenthesis () that may only contain aphanumeric characters between the parentheses. The parentheses can only occur at the end, and nowhere else, must contain both left and right parentheses characters, must be filled with only alphanumeric characters or a forward slash separating alphanumeric characters (not a "lonely" forward slash), and cannot be empty between the left and right parentheses if it DOES occur. After screening, I'd like to also put anything in that was found in parenthesis as its own value as: $str = "Jeans"; $str2 = "10/12"; if it occurs. Do I need to break up each value into two separate strings, then join them; or do I need to screen first to find its existence? I'm lost. I suck. I'm sorry.
|