Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8131691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:09:33+00:00 2026-06-06T09:09:33+00:00

I am using REGEXP_SUBSTR in Oracle 11g and I am having difficulty trying to

  • 0

I am using REGEXP_SUBSTR in Oracle 11g and I am having difficulty trying to extract the following strings.

My query is:

SELECT regexp_substr('CN=aTIGERAdmin-Admin, CN=D0902498, CN=ea90045052, CN=aTIGERCall-Admin,', '[^CN=]*\,', 1, rownum) line
 FROM dual
 CONNECT BY LEVEL <= length('CN=aTIGERAdmin-Admin, CN=D0902498, CN=ea90045052, CN=aTIGERCall-Admin,') - 
                     length(REPLACE('CN=aTIGERAdmin-Admin, CN=D0902498, CN=ea90045052, CN=aTIGERCall-Admin,', ',', ''))

From this query, I am having issues trying to match on exact string ‘CN=’ as from this query, I need the output to appear as follows:

CN=aTIGERAdmin-Admin,
CN=D0902498,
CN=ea90045052,
CN=aTIGERCall-Admin,

And in this format, with the comma at the end.

The way I am doing it at the moment is chopping off the “CN=” but I actually require this part.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T09:09:34+00:00Added an answer on June 6, 2026 at 9:09 am

    I think this will return the resultset you are looking for:

    SELECT REGEXP_SUBSTR(d.s,'CN=.*?,', 1, ROWNUM) line
      FROM (SELECT 'CN=aTIGERAdmin-Admin, CN=D0902498, CN=ea90045052, CN=aTIGERCall-Admin,'
            AS s FROM dual) d
    CONNECT BY LEVEL <= LENGTH(d.s) - LENGTH(REPLACE(d.s,',',''))
    

    The regular expression trick used here is to specify the ? modifier (following the .*) to make the match “non-greedy”. The default match (without the ? modifier) is “greedy” in that it will match as much of the string as possible. In your case, you want the match to end at the first comma found. The intent here is to match literal string ‘CN=’ followed by any number of characters (zero, one or more) up to the first comma encountered.

    This will work in Oracle 10g as well as 11g.

    In 11g, the REGEXP_COUNT function can replace your “count of comman” calculation of occurrences.

    CONNECT BY LEVEL <= REGEXP_COUNT(d.s,'CN=.*?,')
    

    (BTW… by using a subquery to return the literal string, the literal string only has to be specified once. That makes it much easier to change the string for testing, rather than having to change it in multiple places.)


    Addendum:

    I can confirm that the comma is included in the returned value. Sample output:

    LINE
    -----------------------
    CN=aTIGERAdmin-Admin,                                                 
    CN=D0902498,                                                          
    CN=ea90045052,                                                        
    CN=aTIGERCall-Admin, 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to extract text from a column using regular expressions in Oracle 11g.
I'm trying to validate date using PHP. I'd like following formats to be valid:
Using regexp with tokens on cell array of strings I've got cell array of
I'm trying to find eveything inside a div using regexp. I'm aware that there
Using ruby regexp I get the following results: >> 'foobar'[/o+/] => oo >> 'foobar'[/o*/]
I am using the REGEXP_LIKE function in Oracle 10g to find values in a
I'm using the following regexp to validate numbers in my javascript file: var valid
I'm using the following code on my WordPress install: function add_glossary_links($content) { global $wpdb,
I'm having problems using substr() with matches coming from a regular expression (using preg_match()
I'm having a annoying issue with rewrite-using cherokee web-server. I want to convert: http://example.com/mypage.phtml?cmd=print

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.