Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Help with Regexp

Kevin_KNov 16 2024

Oracle REGEXP Gurus:

I am on Oracle 19c

I need to split this string into 3 sections:

section 1 will have first 4 characters

section will have next 4 characters , ignoring leading zeros

section 3 will have last 6 characters until the fist occurrence of zero

Start Date : first data after ;

end date : next data after ; if ‘-’ then end date is NULL

Sample sets:

A01K0151080000;20000101;20051231

A01L0151080000;20000101;-

K01B0009020030;20220101;-

I need :

example 1 : A01K0151080000;20000101;20051231

Section 1 = A01K

Section 2 = 151

Section 3 = 08

Start Date = 20000101

End date = 20051231

Example 2: A01L0151080000;20000101;-

Section 1 = A01K

Section 2 = 151

Section 3 = 08

Start Date = 20000101

End date = NULL ( since the last character is ‘-’)

Example 3 : K01B0009020030;20220101;-

Section 1 = K01B

Section 2 = 9

Section 3 = 02003

Start Date = 20000101

End date = NULL ( since the last character is ‘-’)

Thanks much!

Kevin

Comments
Post Details
Added on Nov 16 2024
11 comments
131 views