Parsing Data
925509Mar 21 2012 — edited Mar 21 2012Hello all ...
here is an example of some data I need to parse.
IN: CS, Test 2A-1, CBL, PHL, South Penn I/L, Loc P10, 49C-Loc P11B, AP 1.5
That code that I have so far:
select t.description,
REGEXP_SUBSTR(t.DESCRIPTION, '[^,]+', 1, 1) col_1,
REGEXP_SUBSTR(t.DESCRIPTION, '[^,]+', 1, 2) col_2,
REGEXP_SUBSTR(t.DESCRIPTION, '[^,]+', 1, 3) col_3,
REGEXP_SUBSTR(t.DESCRIPTION, '[^,]+', 1, 4) col_4,
REGEXP_SUBSTR(t.DESCRIPTION, '[^,]+', 1, 5) col_5,
REGEXP_SUBSTR(t.DESCRIPTION, '[^,]+', 1, 6) col_6,
REGEXP_SUBSTR(t.DESCRIPTION, '[^,]+', 1, 7) Col_7,
REGEXP_SUBSTR(t.DESCRIPTION, '[^,-]+', 1, 9) Col_8,
REGEXP_SUBSTR(t.DESCRIPTION, '[^,]+', 1, 8) col_9,
REGEXP_SUBSTR(t.DESCRIPTION, '[^,]+', 1, 9) col_10,
REGEXP_SUBSTR(t.DESCRIPTION, '[^,]+', 1, 10) col_11
FROM JOBPLAN t
I have 2 problems:
1st problem is that for COL 7, all i want in there is the "49C", I'm currently getting " 49C-Loc P11B".
My ultimate goal is to get any number that is before the C and the C itself. The number before the C could be 1 to 3 digits.
2nd problem
Column 9. That snipit of data will always start with an "A", have another alpha, then a space, then a number. I'm trying to just get the number.
Any help would be greatly appricatiated.