'How to split a string with multiple special characters or delimiters into separate fragments using SQL?
I have a dataset that has a string column as shown below:
| StringCol |
|---|
| abcd_45dl/beta3,test |
| a56d/beta_46ab |
I would like to split each fragment at every special character such as (/,-_^. etc). Currently I am using the following line but this only gives me the first fragment.
SUBSTRING(terms, 0, PATINDEX('%[-!?@#$%^&*()_+=<>.:;/|\]%', terms))
The desired output would like like this:
| StringCol | StringPc |
|---|---|
| abcd_45dl/beta3,test | abcd |
| abcd_45dl/beta3,test | 45dl |
| abcd_45dl/beta3,test | beta3 |
| abcd_45dl/beta3,test | test |
| a56d/beta_46ab | a56d |
| a56d/beta_46ab | beta |
| a56d/beta_46ab | 46ab |
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
