String replace using regular expressions

I'm not very good at regular expressions, but I would like my script to replace
     <a href="somepage.html">
by
<a href="event:somepage">
How do I do this?  Thanks in advance!

Replacing a string that matches a certain pattern with another string is one of the more common RegEx tasks. There is documentation on using them here:
http://livedocs.adobe.com/flex/3/html/help.html?content=12_Using_Regular_Expressions_01.ht ml
hth,
matt horn
flex docs

Similar Messages

  • Changeparticular characters in a string by using regular expressions ...

    Hello Everyone,
    I am trying to write a function by using oracles regular expression function REGEXP_REPLACE but I could not succed till now.
    My problem as follows, I have a text in a column for example let say 'sdfsdf Sdfdfs Sdfd' I want replace all s and S characters with X and make the text look like 'XdfXdf XdfdfX Xdfd'.
    Is it possible by using regular expressions in oracle ?
    Can you give me some clues ?
    Thank you

    SSU wrote:
    Hello Everyone,
    I am trying to write a function by using oracles regular expression function REGEXP_REPLACE but I could not succed till now.
    My problem as follows, I have a text in a column for example let say 'sdfsdf Sdfdfs Sdfd' I want replace all s and S characters with X and make the text look like 'XdfXdf XdfdfX Xdfd'.
    Is it possible by using regular expressions in oracle ?
    Can you give me some clues ?
    Thank you
    SQL> SELECT
      2  regexp_replace('sdfsdf Sdfdfs Sdfd','s|S','X') from dual;
    REGEXP_REPLACE('SD
    XdfXdf XdfdfX XdfdRegards,
    Achyut

  • String extract using regular expression

    Hi
    I have text like this "<a>45</a><ct>Hi</ct><R>45 85</R><H>Here</H>" .I want to extract using regular expression or any techniques the text between <R> and </R> also need to replace the space with pipe between 45 and 85 like "45|85"
    Edited by: vishnu prakash on Mar 2, 2012 4:42 AM

    Hi,
    Here's one way:
    REPLACE ( REGEXP_REPLACE ( txt
                    , '.*<R>(.*)</R>.*'
                    , '\1'
         , '|'
         )This assumes there is only one <R> tag in txt.
    Always say which version of Oracle you're using. The expression above will work in Oralce 10 and up, but starting in Oracle 11 you can use REGEXP_SUBSTR rather than the less intuitive REGEXP_REPLACE.
    Edited by: Frank Kulash on Mar 2, 2012 7:48 AM

  • Find/Replace Using Regular Expressions

    Can someone help me with this...I am using Regular expressions to
    FIND:
    http.*lid=([^&"]*)[^"]*
    REPLACE:
    $set(\1,ID_id,code)$
    So that in the following it will change this:
    a href="http://www.test.com/shc/s/home_10153_12605?lid=Search" rilt="Search"
    To this:
    a href="$set(Search,ID_id,code)$" rilt="Search
    Those expressions  work in Notepad++ but when i use dreamweaver it just replaces the http... with "$set(\1,ID_id,code)$" and doesnt reference the "search"
    Any help?
    Thanks

    Let me begin by saying I'm a complete idiot with DW's Reg Ex.   I use Search Specific Tag whenever possible.  See screenshot below.
    Try this on your Current Document to see if it works. Then make a back-up copy of site before attempting it on Entire Local Site as you cannot "Undo" this process.
    Good luck,
    Nancy O.

  • GUI Based tool for search and replace using regular expression

    Hi,
    I have developed this small tool which can be used for search and replace in multiple files using reqular expressions.
    Features:
    1. Full regular expression
    2. GUI based with Highlighted results
    3. Preview for replace available
    4. Pure Java based.
    5. Its like unix sed and grep
    Please visit below site for download/more information :
    http://sourceforge.net/projects/regexsearchrepl/
    Thanks,
    Hitesh Viseria

    I agree with you, it cannot compete grep/sed/awk combination. I couldnt find anything even close to grep/sed for windows which will also have a preview and most important, free. That is what made me write this tool. I am trying to
    improve its performance and more features like history etc.
    Any suggestions on additional features are most welcome.

  • Splitting html ul tags and their content into string arrays using regular expression

    <ul data-role="listview" data-filter="true" data-inset="true">
    <li data-role="list-divider"></li><li><a href="#"><h3>
    my title
    </h3><p><strong></strong></p></a></li>
    </ul>
    <ul data-role="listview" data-filter="true" data-inset="true">
    <li data-role="list-divider"></li><li>test.</li>
    </ul>
    I need to be able to slip this html into two arrays hold the entire <ul></ul> tag. Please help.
    Thanks.

    Hi friend.
    This forum is to discuss problems of C# development. Your question is not related to the topic of this forum.
    You'll need to post it in the dedicated Archived Forums N-R  > Regular Expressions
     for better support. Thanks for understanding.
    Best Regards,
    Kristin

  • String Manipulation using Regular Expression

    Hello Guys,
    I stuck in a situation wherein I want to extract specific data  from a  column of the table .
    Below are the values for a particular column wherein I want to  ignore  values  along with bracket  which are in bracket and which are like .pdf,.doc .
    Tris(dibenzylideneacetone)dipalladium (0) 451CDHA.pdf
    AM57001A(ASRM549CDH).DOC
    AM23021A Identity of sulfate (draft)
    PG-1183.E.2 (0.25 mg FCT)
    AS149656A (DEV AERO APPL HFA WHT PROVENTIL)
    Stability report (RSR) Annex2 semi-solid form (internal information)
    TSE(Batch#USLF000332)-242CDH, Lancaster synthesis.pdf
    TR3018520A Addendum 1 (PN 3018520)
    AM10311A Particle size air-jet sieving (constant sieving) (draft)
    ASE00099B Addendum (PN E000099) 90 mesh
    AM37101_312-99 (Z11c) Palladium by DCP.doc
    PS21001A_1H-NMR.doc (PN 332-00)
    AM68311A (Q-One CP 33021.02) Attachment
    AM68202-1A (BioReliance no. 02.102006) Attachment
    I want below output for above values for column 
    Trisdipalladium451CDHA
    AM57001A
    AM23021A Identity of sulfate
    PG-1183.E.2
    Thanks in advance

    Like this?
    SQL> with t
      2  as
      3  (
      4  select 'Tris(dibenzylideneacetone)dipalladium (0) 451CDHA.pdf' str from dual
      5  union all
      6  select 'AM57001A(ASRM549CDH).DOC' str from dual
      7  union all
      8  select 'AM23021A Identity of sulfate (draft)' str from dual
      9  union all
    10  select 'PG-1183.E.2 (0.25 mg FCT)' str from dual
    11  union all
    12  select 'AS149656A (DEV AERO APPL HFA WHT PROVENTIL)' str from dual
    13  union all
    14  select 'Stability report (RSR) Annex2 semi-solid form (internal information)' str from dual
    15  union all
    16  select 'TSE(Batch#USLF000332)-242CDH, Lancaster synthesis.pdf' str from dual
    17  union all
    18  select 'TR3018520A Addendum 1 (PN 3018520)' str from dual
    19  union all
    20  select 'AM10311A Particle size air-jet sieving (constant sieving) (draft)' str from dual
    21  union all
    22  select 'ASE00099B Addendum (PN E000099) 90 mesh' str from dual
    23  union all
    24  select 'AM37101_312-99 (Z11c) Palladium by DCP.doc' str from dual
    25  union all
    26  select 'PS21001A_1H-NMR.doc (PN 332-00)' str from dual
    27  union all
    28  select 'AM68311A (Q-One CP 33021.02) Attachment' str from dual
    29  union all
    30  select 'AM68202-1A (BioReliance no. 02.102006) Attachment' str from dual
    31  )
    32  select str
    33      , regexp_replace(str, '(\([^)]+\))|(\..{3})') str_new
    34    from t;
    STR                                                                    STR_NEW
    Tris(dibenzylideneacetone)dipalladium (0) 451CDHA.pdf                  Trisdipalladium  451CDHA
    AM57001A(ASRM549CDH).DOC                                              AM57001A
    AM23021A Identity of sulfate (draft)                                  AM23021A Identity of sulfate
    PG-1183.E.2 (0.25 mg FCT)                                              PG-1183
    AS149656A (DEV AERO APPL HFA WHT PROVENTIL)                            AS149656A
    Stability report (RSR) Annex2 semi-solid form (internal information)  Stability report  Annex2 semi-solid form
    TSE(Batch#USLF000332)-242CDH, Lancaster synthesis.pdf                  TSE-242CDH, Lancaster synthesis
    TR3018520A Addendum 1 (PN 3018520)                                    TR3018520A Addendum 1
    AM10311A Particle size air-jet sieving (constant sieving) (draft)      AM10311A Particle size air-jet sieving
    ASE00099B Addendum (PN E000099) 90 mesh                                ASE00099B Addendum  90 mesh
    AM37101_312-99 (Z11c) Palladium by DCP.doc                            AM37101_312-99  Palladium by DCP
    PS21001A_1H-NMR.doc (PN 332-00)                                        PS21001A_1H-NMR
    AM68311A (Q-One CP 33021.02) Attachment                                AM68311A  Attachment
    AM68202-1A (BioReliance no. 02.102006) Attachment                      AM68202-1A  Attachment
    14 rows selected.

  • Using Regular Expressions to replace Quotes in Strings

    I am writing a program that generates Java files and there are Strings that are used that contain Quotes. I want to use regular expressions to replace " with \" when it is written to the file. The code I was trying to use was:
    String temp = "\"Hello\" i am a \"variable\"";
    temp = temp.replaceAll("\"","\\\\\"");
    however, this does not work and when i print out the code to the file the resulting code appears as:
    String someVar = ""Hello" i am a "variable"";
    and not as:
    String someVar = "\"Hello\" i am a \"variable\"";
    I am assumming my regular expression is wrong. If it is, could someone explain to me how to fix it so that it will work?
    Thanks in advance.

    Thanks, appearently I'm just doing something weird that I just need to look at a little bit harder.

  • Format string using Regular Expression

    Input string output format...
    SELECT q'<select ab_c "ABC", efg "EFG" from dual>' str FROM DUAL
    Output:
    STR                                 
    select ab_c "ABC", efg "EFG" from dual
    Required output format using regular expression...
    STR                                 
    select 'ab_c' "ABC", 'efg' "EFG" from dual

    Regular expressions have many limitations as parsing tools, and you didn't specify the rules you wanted. This expression puts quotes around the non blank string before a quoted string:
    SELECT regexp_replace(q'<select ab_c "ABC", efg "EFG" from dual>',
                          '([^" ]+)( +"[^ ]*")' , '''\1''\2' ) str FROM DUAL;
    STR
    select 'ab_c' "ABC", 'efg' "EFG" from dual
    {code}
    It is not robust - a missing " will confuse it, and you should be using bind variables anyway.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Using regular expressions to get a customized output

    Hi,
    I have a string/varchar variable with the data ',a,b,c,' in it.
    I want the display as follows:
    a
    b
    c
    I would like to get the similar output using regular expressions.
    How do I get this output using REGEXP_REPLACE or REGEXP_SUBSTR?
    Please do the needful.
    Thanks & Regards,
    Rakshit

    I remember that, however if we look closer, that one has a little flaw: The 2nd row should be null, because ",," indicates an empy field. The MODEL clause solution works just fine in this case:
    with t as (select 'aaaa,,bbbb,cccc,dddd,eeee,ffff' col1 from dual)
    -- end of sample data
    SELECT col_new
      FROM t
    MODEL
       PARTITION BY (ROWNUM rn)
       DIMENSION BY (0 dim)
       MEASURES(col1, col1 col_new)
       RULES ITERATE(99) UNTIL (ITERATION_NUMBER = LENGTH(REGEXP_REPLACE(col1[0], '[^,]')))
                    (col_new[ITERATION_NUMBER] = REPLACE(REGEXP_SUBSTR(col1[0], '(^|,)[^,]*', 1, ITERATION_NUMBER+1), ','))
    COL_NEW                                                                                                                                                                  
    aaaa                                                                                                                                                                     
    bbbb                                                                                                                                                                     
    cccc                                                                                                                                                                     
    dddd                                                                                                                                                                     
    eeee
    ffff
    7 Zeilen ausgewählt.Update: I had this nagging feeling that I missed something, and there it was. If you want to see what the problem with my solution is, change the example to
    with t as (select ',aaaa,,bbbb,cccc,dddd,eeee,ffff' col1 from dual)So I went back and tried to fix BlueShadows approach. Here it is:
    with t as (select 'aaaa,,bbbb,cccc,dddd,eeee,ffff' txt from dual)
    -- end of sample data
    SELECT REPLACE(REGEXP_SUBSTR(',' || txt, ',[^,]*', 1, level), ',') col_new
      FROM t
      CONNECT BY level <= length(regexp_replace(txt,'[^,]*'))+1
    ;C.

  • Finding URLs using regular expression.

    I have an requirement where user will type some text containing URLs like "Please visit this site http://www.google.com/e/qHvQcWco`~!@#$%^&*()-7747. Thank you". This text has to be modified as below before saving it to the database.
    "Please visit this site <a href='http://www.google.com/e/qHvQcWco`~!@#$%^&*()-7747'>http://www.google.com/e/qHvQcWco`~!@#$%^&*()-7747</a>. Thank you"
    I am using regular expression (http|https)://.+?\\s which marks the end of the url with a white space character.This pattern doesn't work if the URL is located at the end of the string since there will be no space at the end.
    For example if the string is "Please visit this site http://www.google.com/e/qHvQcWco`~!@#$%^&*()-7747" the regex will fail.
    My acutal problem is to find the URL irrespective its position within the string.
    Pattern urlPattern = Pattern.compile("(http|https)://.+?\\s", Pattern.CASE_INSENSITIVE);
    Matcher matcher = urlPattern.matcher(plainText);
    Map stringIndexMap = new HashMap();
    //Searching the input string for urlPattern...
    while(matcher.find()) {
    String urlString = matcher.group();
    //Storing the urls in a hashmap with their indices as keys....
    stringIndexMap.put(new Integer(matcher.start()), urlString.trim());
    Set keySet = stringIndexMap.keySet();
    Iterator it = keySet.iterator();
    //Iterating over the hashmap containing urls...
    while(it.hasNext()) {
    String urlString = (String) stringIndexMap.get(it.next());
    * Replacing the url string in the input text with <a href="#" onclick="window.open('<urlString>')"
    * using String index
    clickableURLString.replace(clickableURLString.indexOf(urlString),
    clickableURLString.indexOf(urlString) + urlString.length(),
    "<a href=\"#\" onclick=\"window.open('" + urlString
    + "')\">" + urlString + "</a>");
    return clickableURLString.toString();

    The end of the input is '$' as a regex.
    import java.util.regex.*;
    public class Prasanna{
      public static void main(String[] args){
        String text
    = "Please visit this site http://www.google.com/e/qHvQcWco`~!@#$%^&*()-7747";
    //    String regex = "(http|https)://.+?(?:\\s|$)"; // this works
        String regex = "(http|https)://[^ ]+";          // this also works
        Pattern pat = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
        Matcher mat = pat.matcher(text);
        while (mat.find()){
          System.out.println(mat.group());
    }

  • Pattern matching using Regular expression

    Hi,
    I am working on pattern matching using regular expression. I the table, I have 2 columns A and B
    A has value 'A499BPAU4A32A386KBCZ4C13C41D20E'
    B has value like '*CZ4*M11*7NQ+RDR+RSM-R9A-R9B'
    the requirement is that I have to match the columns of B in A. If there is a value with * sign, this must be present in A like 'CZ4' should exit in string A.
    The issue I am facing is that there are 2 values with * sign. The code works fine for first match (CZ4) but it does not look further as M11 does not exist in A.
    I used the condition
    AND instr(A,substr(REGEXP_SUBSTR(B, '*[^*]{3}'),2) ,1)=0
    First of all, is this possible to match multiple patterns in one condition?
    If yes, please suggest.
    Thanks

    user2544469 wrote:
    Thanks a lot Frank. This query worked wonderful for the test data I have provided however I have some concerns:
    - query doesnot include the column BOOK which is a mandatory check.Sorry, that was my mistake. It was a very easy mistake to make, since you posted sample data where it didn't matter. Instead of doing a cross-join between vn and got_must_have_cnt, do an inner join, using book. That means book will have to be in got_must_have_cnt, and all the sub-queries from which it descends. Look for comments that say "March 22".
    If you want to treat '+' in test_cat.codes as '*', then the simplest thing is probably just to use REPLACE, so that when the table has '+', you use '*' instead.
    WITH     got_token_cnt     AS
         SELECT     cat
         ,     book                                        -- Added March 22
         ,     REPLACE (codes, '+', '*') AS codes                    -- If desired.  Changed March 22
         ,     LENGTH (codes) - LENGTH ( TRANSLATE ( codes
                                                       , 'x*+-'
                                      , 'x'
                             ) AS token_cnt
         FROM    test_cat
    ,     cntr     AS
         SELECT     LEVEL     AS n
         FROM     (  SELECT  MAX (token_cnt)     AS max_token_cnt
                 FROM        got_token_cnt
         CONNECT BY     LEVEL     <= max_token_cnt
    ,     got_tokens     AS
         SELECT     t.cat
         ,     t.book                                        -- Added March 22
         ,     REGEXP_SUBSTR ( t.codes
                         , '[*+-]'
                         , 1
                         , c.n
                         )          AS token_type
         ,     SUBSTR ( REGEXP_SUBSTR ( t.codes
                                       , '[*+-][^*+-]*'
                               , 1
                               , c.n
                   , 2
                   )          AS token
         FROM     got_token_cnt     t
         JOIN     cntr          c  ON     c.n     <= t.token_cnt
    ,     got_must_have_cnt     AS
         SELECT       cat, book                                   -- Changed March 22
         ,       COUNT (CASE WHEN token_type = '*' THEN 1 END) AS must_have_cnt
         FROM       got_tokens
         GROUP BY  cat, book                                   -- Changed March 22
    SELECT       mh.cat
    ,       vn.vn_no
    FROM       got_must_have_cnt     mh
    JOIN                    vn  ON  mh.book     = vn.book               -- Changed March 22
    LEFT OUTER JOIN      got_tokens     gt  ON     mh.cat                  = gt.cat
                                     AND INSTR (vn.codes, gt.token) > 1
    GROUP BY  mh.cat
    ,            mh.must_have_cnt
    ,            vn.vn_no
    HAVING       COUNT (CASE WHEN gt.token_type = '*' THEN 1 END)     = mh.must_have_cnt
    AND       COUNT (CASE WHEN gt.token_type = '-' THEN 1 END)     = 0
    ORDER BY  mh.cat
    - query is very slow with 60000 records in vn table. Cost is somewhere around 36000.See these threads:
    When your query takes too long ...
    HOW TO: Post a SQL statement tuning request - template posting
    Relational databases were designed to have (at most) one piece of information in each column. If you decide to have multiple items in the same column (as you have a variable number of tokens in the codes column), don't be surprised if that makes things slower and more complicated. Most of the query I posted, and perhaps most of the time needed, is jsut to normalize the data. If you stored the data in a narmalized form, perhaps something like got_tokens, then you wouldn't need the first 3 sub-queries that I posted.
    Edited by: Frank Kulash on Mar 22, 2011 12:04 PM

  • Procedure using regular expression

    How to write a procedure using regular expression where i pass a string as input
    The procedure should check whether it is a valid email address or not
    Please help me

    Hello,
    perhaps you don't need to code it, because it's already there.
    When you use the database to send your mails it or the appropriate package throws the exception
    ORA-29279: Permanenter SMTP-Fehler: 501 5.5.4 Invalid Address
    When you just need a procedure to check it you can write a wrapper for a java function.
    import javax.mail.internet.*;
    import oracle.sql.NUMBER;
    public class mail_utility {
      public static NUMBER validate_address(String rfc822Address) {
        int rc = 0;
        try {
          InternetAddress ia = new InternetAddress(rfc822Address);
          rc = 1;
        } catch (AddressException ae) {
          rc = 0;
        } catch (Exception e) {
          rc = -1;
        } finally {
          return new NUMBER(rc);
    CREATE OR REPLACE  FUNCTION VALIDATE_ADDRESS (p_address in varchar2)
    return number
    as language java name
      'mail_utility.validate_address(java.lang.String) return oracle.sql.NUMBER';I think i've got it from the forum but i don't remember from whom.
    Bernd

  • Request some help, over procedure's performance uses regular expressions for its functinality

    Hi All,
            Below is the procedure, having functionalities of populating two tables. For first table, its a simple insertion process but for second table, we need to break the soruce record as per business requirement and then insert into the table. [Have used regular expressions for that]
            Procedure works fine but it takes around 23 mins for processing 1mm of rows.
            Since this procedure would be used, parallely by different ETL processes, so append hint is not recommended.
            Is there any ways to improve its performance, or any suggestion if my approach is not optimized?  Thanks for all help in advance.
    CREATE OR REPLACE PROCEDURE SONARDBO.PRC_PROCESS_EXCEPTIONS_LOGS_TT
         P_PROCESS_ID       IN        NUMBER, 
         P_FEED_ID          IN        NUMBER,
         P_TABLE_NAME       IN        VARCHAR2,
         P_FEED_RECORD      IN        VARCHAR2,
         P_EXCEPTION_RECORD IN        VARCHAR2
        IS
        PRAGMA AUTONOMOUS_TRANSACTION;
        V_EXCEPTION_LOG_ID     EXCEPTION_LOG.EXCEPTION_LOG_ID%TYPE;
        BEGIN
        V_EXCEPTION_LOG_ID :=EXCEPTION_LOG_SEQ.NEXTVAL;
             INSERT INTO SONARDBO.EXCEPTION_LOG
                 EXCEPTION_LOG_ID, PROCESS_DATE, PROCESS_ID,EXCEPTION_CODE,FEED_ID,SP_NAME
                ,ATTRIBUTE_NAME,TABLE_NAME,EXCEPTION_RECORD
                ,DATA_STRUCTURE
                ,CREATED_BY,CREATED_TS
             VALUES           
             (   V_EXCEPTION_LOG_ID
                ,TRUNC(SYSDATE)
                ,P_PROCESS_ID
                ,'N/A'
                ,P_FEED_ID
                ,NULL 
                ,NULL
                ,P_TABLE_NAME
                ,P_FEED_RECORD
                ,NULL
                ,USER
                ,SYSDATE  
            INSERT INTO EXCEPTION_ATTR_LOG
                EXCEPTION_ATTR_ID,EXCEPTION_LOG_ID,EXCEPTION_CODE,ATTRIBUTE_NAME,SP_NAME,TABLE_NAME,CREATED_BY,CREATED_TS,ATTRIBUTE_VALUE
            SELECT
                EXCEPTION_ATTR_LOG_SEQ.NEXTVAL          EXCEPTION_ATTR_ID
                ,V_EXCEPTION_LOG_ID                     EXCEPTION_LOG_ID
                ,REGEXP_SUBSTR(str,'[^|]*',1,1)         EXCEPTION_CODE
                ,REGEXP_SUBSTR(str,'[^|]+',1,2)         ATTRIBUTE_NAME
                ,'N/A'                                  SP_NAME    
                ,p_table_name
                ,USER
                ,SYSDATE
                ,REGEXP_SUBSTR(str,'[^|]+',1,3)         ATTRIBUTE_VALUE
            FROM
            SELECT
                 REGEXP_SUBSTR(P_EXCEPTION_RECORD, '([^^])+', 1,t2.COLUMN_VALUE) str
            FROM
                DUAL t1 CROSS JOIN
                        TABLE
                            CAST
                                MULTISET
                                    SELECT LEVEL
                                    FROM DUAL
                                    CONNECT BY LEVEL <= REGEXP_COUNT(P_EXCEPTION_RECORD, '([^^])+')
                                AS SYS.odciNumberList
                        ) t2
            WHERE REGEXP_SUBSTR(str,'[^|]*',1,1) IS NOT NULL
            COMMIT;
           EXCEPTION
             WHEN OTHERS THEN
             ROLLBACK;
             RAISE;
        END;
    Many Thanks,
    Arpit

    Regex's are known to be CPU intensive specially when dealing with large number of rows.
    If you have to reduce the processing time, you need to tune the Select statements.
    One suggested change could be to change the following query
    SELECT
                 REGEXP_SUBSTR(P_EXCEPTION_RECORD, '([^^])+', 1,t2.COLUMN_VALUE) str
            FROM
                DUAL t1 CROSS JOIN
                        TABLE
                            CAST
                                MULTISET
                                    SELECT LEVEL
                                    FROM DUAL
                                    CONNECT BY LEVEL <= REGEXP_COUNT(P_EXCEPTION_RECORD, '([^^])+')
                                AS SYS.odciNumberList
                        ) t2
    to
    SELECT REGEXP_SUBSTR(P_EXCEPTION_RECORD, '([^^])+', 1,level) str
    FROM DUAL
    CONNECT BY LEVEL <= REGEXP_COUNT(P_EXCEPTION_RECORD, '([^^])+')
    Before looking for any performance benefit, you need to ensure that this does not change your output.
    How many substrings are you expecting in the P_EXCEPTION_RECORD? If less than 5, it will be better to opt for SUBSTR and INSTR combination as it might work well with the number of records you are working with. Only trouble is, you will have to write different SUBSTR and INSTR statements for each column to be fetched.
    How are you calling this procedure? Is it not possible to work with Collections? Delimited strings are not a very good option as it requires splitting of the data every time you need to refer to.

  • One for the Tekkies: How to get this output using REGULAR EXPRESSIONS?

    How to get the below output using REGULAR EXPRESSIONS??
    SQL> ed
    Wrote file afiedt.buf
      1* CREATE TABLE cus___addresses    (full_address                   VARCHAR2(200 BYTE))
    SQL> /
    Table created.
    SQL> PROMPT Address Format is: House #/Housename,  street,  City, Zip Code, COUNTRY
    House #/Housename,  street,  City, Zip Code, COUNTRY
    SQL> INSERT INTO cus___addresses VALUES('1, 3rd street, Lansing, MI 49001, USA');
    1 row created.
    SQL> INSERT INTO cus___addresses VALUES('3B, fifth street, Clinton, OK 74103, USA');
    1 row created.
    SQL> INSERT INTO cus___addresses VALUES('Rose Villa, Stanton Grove, Murray, TN 37183, USA');
    1 row created.
    SQL> SELECT * FROM cus___addresses;
    FULL_ADDRESS
    1, 3rd street, Lansing, MI 49001, USA
    3B, fifth street, Clinton, OK 74103, USA
    Rose Villa, Stanton Grove, Murray, TN 37183, USA
    SQL> The REG EXP query shouLd output the ZIP codes: i.e. 49001, 74103, 37183 in 3 rows.Edited by: user12240205 on Jun 18, 2012 3:19 AM

    Hi,
    user12240205 wrote:
    ... Frank, ʃʃp's method, I understand. But your method, although correct, I find it difficult to understand.
    Could you explain how you did this?? What does '.*(\d{5})\D*' and '\1' mean???
    Your method is better because it uses only ONE reg expression function. ʃʃp's uses 2.In Oracle 10.2 (I believe) and higher, '\d' is equivalent to '[[:digit:]]', and '\D' is equivalent to '[^[:digit:]]'. I find '\d' and '\D' easier to type, but there's nothing wrong with using '[[:digit:]]' and '[^[:digit:]]'.
    '.*' means "0 or more of any character".
    '\D*' means "0 or more non-digits".
    The whole expression, '.*(\d{5})\D*' means:
    a. 0 or more characters (any characters)
    b. 5 digits
    c. 0 or more non-digits.
    '\1' is a Backreference . It means the sub-string that matched the pattern after the 1st '(', up to (but not including) its matching ')'. In this case, that means the sub-string that matched '\d{5}', or b. using the explanation immediately above.
    So the entire REGEXP_REPLACE call means "When you see a sub-string consisting of a., follwed immediately by b., followed immedately by c., replace that sub-string with b. alone."

Maybe you are looking for