![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, I have a problem, I found on internet a way to split strings separated by pipe | (for example) with regexp, something like that: SELECT REGEXP_SUBSTR('One|Two|Three|Four','[^|]+', 1, 3) FROM dual; which gives the result: Three the problem comes when I have one of the words separated by the pipe is actually a Null, so the string becomes 'One|Two||Four|' the query SELECT REGEXP_SUBSTR('One|Two||Four','[^|]+', 1, 3) FROM dual; result in: Four I needed a Null (or empty string). How is this possible? Thank you in advance! |
#3
| |||
| |||
|
|
Hi, I have a problem, I found on internet a way to split strings separated by pipe | (for example) with regexp, something like that: SELECT REGEXP_SUBSTR('One|Two|Three|Four','[^|]+', 1, 3) FROM dual; which gives the result: Three the problem comes when I have one of the words separated by the pipe is actually a Null, so the string becomes 'One|Two||Four|' the query SELECT REGEXP_SUBSTR('One|Two||Four','[^|]+', 1, 3) FROM dual; result in: Four I needed a Null (or empty string). How is this possible? Thank you in advance! |
#4
| |||
| |||
|
|
Hi, I have a problem, I found on internet a way to split strings separated by pipe | (for example) with regexp, something like that: SELECT REGEXP_SUBSTR('One|Two|Three|Four','[^|]+', 1, 3) FROM dual; which gives the result: Three the problem comes when I have one of the words separated by the pipe is actually a Null, so the string becomes 'One|Two||Four|' the query SELECT REGEXP_SUBSTR('One|Two||Four','[^|]+', 1, 3) FROM dual; result in: Four I needed a Null (or empty string). How is this possible? Thank you in advance! |
#5
| |||
| |||
|
|
Hi, I have a problem, I found on internet a way to split strings separated by pipe | (for example) with regexp, something like that: SELECT REGEXP_SUBSTR('One|Two|Three|Four','[^|]+', 1, 3) FROM dual; which gives the result: Three the problem comes when I have one of the words separated by the pipe is actually a Null, so the string becomes 'One|Two||Four|' the query SELECT REGEXP_SUBSTR('One|Two||Four','[^|]+', 1, 3) FROM dual; result in: Four I needed a Null (or empty string). How is this possible? Thank you in advance! |
#6
| |||
| |||
|
|
On Feb 28, 11:02=A0am, citte <nicola.ame... (AT) gmail (DOT) com> wrote: Hi, I have a problem, I found on internet a way to split strings separated by pipe | (for example) with regexp, something like that: SELECT REGEXP_SUBSTR('One|Two|Three|Four','[^|]+', 1, 3) FROM dual; which gives the result: Three the problem comes when I have one of the words separated by the pipe is actually a Null, so the string becomes 'One|Two||Four|' the query SELECT REGEXP_SUBSTR('One|Two||Four','[^|]+', 1, 3) FROM dual; result in: Four I needed a Null (or empty string). How is this possible? Thank you in advance! Will this help? SQL> l 1 select regexp_substr(replace('one|two||four','||','|NULL| '), 2* '[^|]+',1,3) from dual SQL> / REGE ---- NULL |
|
Also to return an actual NULL value SQL> select regexp_substr(replace('one|two||four','||',''), 2 '[^|]+',1,3) from dual; R - |
#7
| |||
| |||
|
|
On Feb 28, 11:02=A0am, citte <nicola.ame... (AT) gmail (DOT) com> wrote: Hi, I have a problem, I found on internet a way to split strings separated by pipe | (for example) with regexp, something like that: SELECT REGEXP_SUBSTR('One|Two|Three|Four','[^|]+', 1, 3) FROM dual; which gives the result: Three the problem comes when I have one of the words separated by the pipe is actually a Null, so the string becomes 'One|Two||Four|' the query SELECT REGEXP_SUBSTR('One|Two||Four','[^|]+', 1, 3) FROM dual; result in: Four I needed a Null (or empty string). How is this possible? Thank you in advance! Will this help? SQL> l 1 select regexp_substr(replace('one|two||four','||','|NULL| '), 2* '[^|]+',1,3) from dual SQL> / REGE ---- NULL |
|
Also to return an actual NULL value SQL> select regexp_substr(replace('one|two||four','||',''), 2 '[^|]+',1,3) from dual; R - |
#8
| |||
| |||
|
|
On Feb 28, 11:02=A0am, citte <nicola.ame... (AT) gmail (DOT) com> wrote: Hi, I have a problem, I found on internet a way to split strings separated by pipe | (for example) with regexp, something like that: SELECT REGEXP_SUBSTR('One|Two|Three|Four','[^|]+', 1, 3) FROM dual; which gives the result: Three the problem comes when I have one of the words separated by the pipe is actually a Null, so the string becomes 'One|Two||Four|' the query SELECT REGEXP_SUBSTR('One|Two||Four','[^|]+', 1, 3) FROM dual; result in: Four I needed a Null (or empty string). How is this possible? Thank you in advance! Will this help? SQL> l 1 select regexp_substr(replace('one|two||four','||','|NULL| '), 2* '[^|]+',1,3) from dual SQL> / REGE ---- NULL |
|
Also to return an actual NULL value SQL> select regexp_substr(replace('one|two||four','||',''), 2 '[^|]+',1,3) from dual; R - |
#9
| |||
| |||
|
|
On Feb 28, 11:02=A0am, citte <nicola.ame... (AT) gmail (DOT) com> wrote: Hi, I have a problem, I found on internet a way to split strings separated by pipe | (for example) with regexp, something like that: SELECT REGEXP_SUBSTR('One|Two|Three|Four','[^|]+', 1, 3) FROM dual; which gives the result: Three the problem comes when I have one of the words separated by the pipe is actually a Null, so the string becomes 'One|Two||Four|' the query SELECT REGEXP_SUBSTR('One|Two||Four','[^|]+', 1, 3) FROM dual; result in: Four I needed a Null (or empty string). How is this possible? Thank you in advance! Will this help? SQL> l 1 select regexp_substr(replace('one|two||four','||','|NULL| '), 2* '[^|]+',1,3) from dual SQL> / REGE ---- NULL |
|
Also to return an actual NULL value SQL> select regexp_substr(replace('one|two||four','||',''), 2 '[^|]+',1,3) from dual; R - |
#10
| |||
| |||
|
|
Hi, I have a problem, I found on internet a way to split strings separated by pipe | (for example) with regexp, something like that: SELECT REGEXP_SUBSTR('One|Two|Three|Four','[^|]+', 1, 3) FROM dual; which gives the result: Three the problem comes when I have one of the words separated by the pipe is actually a Null, so the string becomes 'One|Two||Four|' the query SELECT REGEXP_SUBSTR('One|Two||Four','[^|]+', 1, 3) FROM dual; result in: Four I needed a Null (or empty string). How is this possible? |
![]() |
| Thread Tools | |
| Display Modes | |
| |