I have to put a string after every 5 characters in a given string (varchar2). Given string can have different length. I already solved it by a loop using substrings. Is there any way i could reach the goal using REGEXP in Oracle DB?
            Asked
            
        
        
            Active
            
        
            Viewed 85 times
        
    1 Answers
3
            You can use REGEXP_REPLACE to replace every 5 characters with those 5 characters followed by another string. For example:
SELECT REGEXP_REPLACE('ABCDE12345FGHIJ67890KL', '(.{5})', '\1*') FROM DUAL
Output:
ABCDE*12345*FGHIJ*67890*KL
 
    
    
        Nick
        
- 138,499
- 22
- 57
- 95
