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!

Extract part of string

user545194Dec 2 2025 — edited Dec 2 2025

19c SE2

I need to extract a part of a string, like just the street address:

777 Brockton Avenue

I have tried this, but I need the text before the comma.

WITH data AS 
 ( 
 SELECT '777 Brockton Avenue, Abington MA 2351' str FROM dual 
 ) 
 SELECT str, 
 REGEXP_SUBSTR(str, '[^,]+$') new_str 
 FROM data;
 --Solution
 WITH data AS
 (
   SELECT '777 Brockton Avenue, Abington MA 2351' str FROM dual
 )
 SELECT str,
        REGEXP_SUBSTR(str, '[^,]+') new_str
 FROM data;

Thanks!

Comments
Post Details
Added on Dec 2 2025
6 comments
163 views