1
PSOUG / REGEXP_SUBSTR Function usage
« on: August 10, 2011, 01:32:37 pm »
I am attempting to extract substrings out of a string (ex. '001.069012...3301').
From the sting I wish to treat the period (.) as the delimiter. As such there are 5 substrings in this string with the third and fourth having a null value. I am currently using the following code to do this:
REGEXP_SUBSTR( ALS.CONCATENATED_SEGMENTS, '[^.]+', 1, 1 ) SUBST_1
This code (which I got off of this wesite, Thanks Mike!) works great as long as there are no empty (null) substrings in the string.
Right now in order to get the 5th substring, I am actually using 3 for the occurance arguement.
Any suggestions on how to get this to work so it can handle empty (null) substrings?
Side note: for those of you familiar with MUMPS, this would work like the $PIECE function.
Thank you for a great website Mike. You have lots of great content here! :-)
From the sting I wish to treat the period (.) as the delimiter. As such there are 5 substrings in this string with the third and fourth having a null value. I am currently using the following code to do this:
REGEXP_SUBSTR( ALS.CONCATENATED_SEGMENTS, '[^.]+', 1, 1 ) SUBST_1
This code (which I got off of this wesite, Thanks Mike!) works great as long as there are no empty (null) substrings in the string.
Right now in order to get the 5th substring, I am actually using 3 for the occurance arguement.
Any suggestions on how to get this to work so it can handle empty (null) substrings?
Side note: for those of you familiar with MUMPS, this would work like the $PIECE function.
Thank you for a great website Mike. You have lots of great content here! :-)