REGEXP_REPLACE question

Hi Everyone,
I have a unique scenario in where I need to use the regexp_replace function to accomodate what the client is looking for. Here is the scenario, they have field for an address that has ''1000 Jefferson's Hou'snty Parkway" and they want the 's' in Jefferson's to stay lower case but the 's' in Cou'snty should be upper case. So the regexp_replace function needs to look at the string '1000 Jefferson's Hou'snty Parkway' and understand that if the 's is at the very end then it needs to be lower case but the other one needs to be 'S.
Here is what I have so far but it only takes care of the Jefferson's scenario but not the Hou'snty word. Can you help me in writing the correct expression for this scenario?
select regexp_replace(ADDRESS_1, '''S$','''s')
from MY_TABLE
Thanks for your help.

user11089573 wrote:
Thank you Frank. I just tested it out and it is working! But I'd like to fully understand the expression you wrote.
What is this 's(\S)' and '''S\1' doing?In the 3nd argument, '\1' is a Backreference . It means the part of the expression in the 2nd argument inside the 1st left '(' and its matching right ')'. In this case, that means the non-spacing character (space, tab, newline) that matched \S
It might be easier to understand with some in-line comments:
SELECT     REGEXP_REPLACE ( address_1
                 , '''s'   || -- apostrophe and lower-case s
                       '(\S)'         -- \1, which is any non whitespace character
                 , '''S'      || -- apostrophe and capital-S
                   '\1'         -- whatever \1 was
                 )          AS new_adddress_1

Similar Messages

  • Regexp_replace and regexp_substr questions

    Hello,
    I am new to regular expressions. Need help with following :
    1. Need to remove duplicate alphanumeric string followed by space character.
    Input : 'SAY HELLO HELLO HELLO WORLD'
    Output: 'SAY HELLO WORLD'
    Input : 'MY STRING STRING HAS DUPLICATES'
    Output: 'MY STRING HAS DUPLICATES'
    2. Parsing.
    Input1 : 'APT D67 1023 MAIN ST BUFFALO NY'
    or
    Input2 : '1023 MAIN ST APT D67 BUFFALO NY'
    Extract the following: 'APT D67 '
    Output: '1023 MAIN ST BUFFALO NY' , 'APT D67'
    How to extract substr using regexp? 'D67' is alphanumeric value might neccesserely appear after APT. Regexp_instr?
    3. Is it solution to use regexpr to eliminate duplicates in the following case ?
    Input : _'APT 789_ 456 FLOWER DR APT 789 VALEJIA CA'
    Output: 'APT 789 456 FLOWER DR VALEJIA CA'
    Thanks in advance.

    REgards salim.
    WITH T AS
         (SELECT  'SAY HELLO HELLO HELLO WORLD'     TXT
                FROM DUAL
        UNION ALL
         SELECT 'APT 789 456 FLOWER DR APT 789 VALEJIA CA'
               FROM DUAL
          UNION ALL
          SELECT      'MY STRING STRING HAS DUPLICATES'
          FROM DUAL
        SELECT TXT|| case when apt is not null then ' ,'|| APT end    txt
      FROM (
             SELECT   distinct  RN,TXT ,rang,apt
             FROM   T
            MODEL
              RETURN UPDATED ROWS
               PARTITION BY ( ROWNUM RN)
               DIMENSION BY (0 POSITION)
             MEASURES     (TXT ,NVL(LENGTH(REGEXP_REPLACE(TXT,'[^ ]+','')),0)+1 NB_MOT, 0 rang,
             REGEXP_SUBSTR(TXT,'^APT [0-9]+') apt)
              RULES
              (TXT[FOR POSITION FROM  1 TO NB_MOT[0] INCREMENT 1]  =
               REGEXP_SUBSTR(TXT[0],'[^ ]+',1,CV(POSITION)) ,
               APT[FOR POSITION FROM  1 TO NB_MOT[0] INCREMENT 1]  =
               REGEXP_SUBSTR(TXT[0],'^APT [0-9]+'),
                rang[position>=1]=  instr(txt[0],txt[cv()],1)) )
      MODEL
      RETURN UPDATED ROWS
    PARTITION BY (  RN,APT )
      DIMENSION BY ( ROW_NUMBER() OVER (PARTITION BY RN ORDER BY rang ASC) AS POSITION)
      MEASURES ( CAST( TXT AS VARCHAR2(1000) ) AS TXT  )
       RULES
      UPSERT
      ITERATE( 1000)
    UNTIL ( PRESENTV(TXT[ITERATION_NUMBER+2],1,0) = 0 )
      (TXT[0] = TXT[0] ||   CASE WHEN ITERATION_NUMBER+1=1 AND TXT[ITERATION_NUMBER+1]='APT' THEN NULL
                             WHEN ITERATION_NUMBER+1=2 AND TXT[ITERATION_NUMBER]  ='APT' THEN NULL
                              ELSE   ' ' || TXT[ITERATION_NUMBER+1] END )
       ORDER BY rn
    SQL> WITH T AS
      2       (SELECT  'SAY HELLO HELLO HELLO WORLD'     TXT
      3              FROM DUAL
      4      UNION ALL
      5       SELECT 'APT 789 456 FLOWER DR APT 789 VALEJIA CA' 
      6             FROM DUAL
      7        UNION ALL
      8        SELECT      'MY STRING STRING HAS DUPLICATES'
      9        FROM DUAL
    10     )
    11      SELECT TXT|| case when apt is not null then ' ,'|| APT end    txt
    12    FROM (
    13           SELECT   distinct  RN,TXT ,rang,apt
    14           FROM   T
    15          MODEL
    16            RETURN UPDATED ROWS
    17             PARTITION BY ( ROWNUM RN)
    18             DIMENSION BY (0 POSITION)
    19           MEASURES     (TXT ,NVL(LENGTH(REGEXP_REPLACE(TXT,'[^ ]+','')),0)+1 NB_MOT, 0 rang,   
    20           REGEXP_SUBSTR(TXT,'^APT [0-9]+') apt)
    21            RULES
    22            (TXT[FOR POSITION FROM  1 TO NB_MOT[0] INCREMENT 1]  =
    23             REGEXP_SUBSTR(TXT[0],'[^ ]+',1,CV(POSITION)) ,
    24             APT[FOR POSITION FROM  1 TO NB_MOT[0] INCREMENT 1]  =
    25             REGEXP_SUBSTR(TXT[0],'^APT [0-9]+'),
    26              rang[position>=1]=  instr(txt[0],txt[cv()],1)) )
    27    MODEL
    28    RETURN UPDATED ROWS
    29   PARTITION BY (  RN,APT )
    30    DIMENSION BY ( ROW_NUMBER() OVER (PARTITION BY RN ORDER BY rang ASC) AS POSITION)
    31    MEASURES ( CAST( TXT AS VARCHAR2(1000) ) AS TXT  )
    32     RULES
    33    UPSERT
    34    ITERATE( 1000)
    35   UNTIL ( PRESENTV(TXT[ITERATION_NUMBER+2],1,0) = 0 )
    36    (TXT[0] = TXT[0] ||   CASE WHEN ITERATION_NUMBER+1=1 AND TXT[ITERATION_NUMBER+1]='APT' THEN N
    ULL
    37                           WHEN ITERATION_NUMBER+1=2 AND TXT[ITERATION_NUMBER]  ='APT' THEN NULL
    38                            ELSE   ' ' || TXT[ITERATION_NUMBER+1] END )
    39     ORDER BY rn
    40  /
    TXT
    SAY HELLO WORLD
    456 FLOWER DR VALEJIA CA ,APT 789
    MY STRING HAS DUPLICATES
    SQL>  Edited by: Salim Chelabi on 2009-04-06 14:05
    Edited by: Salim Chelabi on Apr 6, 2009 4:11 PM

  • Regexp_replace to remove blank lines from multi lines in a single field

    Gents. 10g R2.
       with test_tab as
       (select 'x'||chr(10)||'y'||chr(10)||chr(10)||'z' tester from dual)
       select tester from test_tabproduces
    x
    y
    zI require
    x
    y
    zThere's a lot of examples on how to end up with xzy, but I need to maintain the carriage returns, just strip out blank lines.
    I've been trying with posix [:cntrl:] but it doesn't seem to want to work. Question: how to get the desired output?
    If this has been answered on another post, please point me in the right direction and accept my apologies!

    Hi,
    The simplest thing might be to use LTRIM. (or TRIM, if you need to remove them from the end of the string, as well).
    If you want a regular expression:
    SELECT     REGEXP_REPLACE ( tester
                     , '(^|' || CHR (10) || ')' || CHR (10) || '+'
                     , '\1'
    FROM     test_tab
    ;This might be easier to understand if you let x stand for CHR (10):
    SELECT     REGEXP_REPLACE ( tester
                     , '(^|x)x+'
                     , '\1'
    FROM     test_tab
    ;This is easier to understand: \1 is either the beginning of the string or x. When this is followed imeediately by 1 or more extra x's, then replace that whole pattern with \1 (that is, remove the extra x's).

  • How can I transfer a variable to regexp_replace function

    Hi,
    In addition to my question from yesterday, I went up one (little) level for the next question.
    How can I transfer a variable to regexp_replace function?
    I am getting the value of the variables from from APEX Items.
    The value of item :P105_OLD_NAME should be replaced with the value from :P105_NAME APEX item.
    The projects in PROJECT_NAME field are separated by “:”
    select * from infoux_proj;
    HOSTNAME PROJECT_NAME
    host1 proj2:proj1
    host3 proj1
    host4 proj12:proj1
    host5 proj3
    host2 proj1:proj3:sunproj1
    this is my code:
    declare
    v_old_proj_list varchar(100);
    v_new_proj_list varchar(100);
    begin
    for host in (select a.hostname, project_name
    from infoux_proj a,
    (select hostname
    from PROJECT_NAMES_WITH_HOSTNAMES
    where name = :P105_OLD_NAME ) b
    where a.HOSTNAME=b.hostname)
    loop
    select project_name ,
    regexp_replace(project_name,'(^|:)(:P105_OLD_NAME)(:|$)','\1:P105_NAME \3') new_project
    into v_old_proj_list, v_new_proj_list
    from infoux_proj
    where hostname=host.hostname;
    update infoux_proj
    set project_name=v_new_proj_list
    where hostname=host.hostname;
    end loop;
    end;
    Thanks,
    Sheli

    Hi, Sheli
    Inside quotes, :p105_old_name will not be taken as a variable name. If you want to use the value of :p105_old_name in a string which its otherwise a literal, then you can concatenate the variable to the literal parts, using the || operator.
    You can do soemthing like this:
    REGEXP_REPLACE ( project_name
                , '(^|:)(' || :P105_OLD_NAME
                             || ')(:|$)'
                , '\1'       || :P105_NAME
                             || ' \3'
                )               AS new_projectI'll bet there's a much simpler way to do what you want. Instead of having two SELECTs, a cursor FOR loop and an UPDATE, you can probably do what you need to with just a single UPDATE or MERGE. It would be more efficient, too. If you'd like help, post CREATE TABLE and INSERT statements for all relevant tables and columns azs the exist before this code is run, a couple of sets of values for the bind variables, and the results you'd like to see (that is, the contents of the changed table) for each set, given the same sample data.
    Always say which version of Oracle you're using.

  • Referencing REGEXP_REPLACE capture in other function

    Here's the deal...
    I've got a clob that I'm scrubbing with REGEXP_REPLACE to remove the instance of a specific string, then I want to use that string in a function call. I can see the string (on line 2 below) but can't get the function in line 3 to utilize it.
    THE CODE
    1 SELECT regexp_replace(wrk_clob, 'href=\s*"([^"]+)"',
    2                    || '\1' || ':'
    3                    || get_id_list(in_table, in_state, '\1')
    4 INTO wrk_clob
    5 FROM dual;
    THE FUNCTION SPEC
    FUNCTION get_id_list(
                   in_table VARCHAR2,
                   in_state VARCHAR2,
                   in_doc_name VARCHAR2)
                             RETURN VARCHAR;
    If I hardcode the value from line 4 into the in_doc_name position it returns properly. However, it does nothing - because '\1' does not point to any data - with this reference.
    Any ideas where to go with this?
    Thanks.
    fordo82

    Look here:
    SQL> with t as (select '"111111" href="111"222' str from dual)
      2  select regexp_replace(str, 'href=\s*"([^"]+)"', '\1:'||decode(1,2,'asd','qwe')) yours,
      3         regexp_replace(str, 'href=\s*"([^"]+)"', '\1') yours2,
      4         regexp_replace(str, '.*?href=\s*"([^"]+)".*', '\1') mine,
      5         regexp_substr(str, 'href=\s*"([^"]+)"') subs1
      6          from t
      7  /
    YOURS               YOURS2          MINE SUBS1
    "111111" 111:qwe222 "111111" 111222 111  href="111"
    SQL> If any questions rest - ask.
    Message was edited by:
    Volder
    Whereas the piece that I have currently - regexp_replace(wrk_clob, 'href=\s*"([^"]+)"', - will cut out what the pieces I don't want.Can you provide an example of wrk_clob, and the result - you expect to get with this regexp_replace?

  • Easy Question: How to split concatenated string into multiple rows?

    Hi folks,
    this might be an easy question.
    How can I split a concatenated string into multiple rows using SQL query?
    INPUT:
    select 'AAA,BBB,CC,DDDD' as data from dualDelimiter = ','
    Expected output:
    data
    AAA
    BBB
    CCC
    DDDDI'm looking for something kind of "an opposite for 'sys_connect_by_path'" function.
    Thanks,
    Tomas

    Here is the SUBSTR/INSTR version of the solution:
    SQL> WITH test_data AS
      2  (
      3          SELECT ',' || 'AAA,BBB,CC,DDDD' || ',' AS DATA FROM DUAL
      4  )
      5  SELECT  SUBSTR
      6          (
      7                  DATA
      8          ,       INSTR
      9                  (
    10                          DATA
    11                  ,       ','
    12                  ,       1
    13                  ,       LEVEL
    14                  ) + 1
    15          ,       INSTR
    16                  (
    17                          DATA
    18                  ,       ','
    19                  ,       1
    20                  ,       LEVEL + 1
    21                  ) -
    22                  INSTR
    23                  (
    24                          DATA
    25                  ,       ','
    26                  ,       1
    27                  ,       LEVEL
    28                  ) - 1
    29          )       AS NEW_STRING
    30  FROM    test_data
    31  CONNECT BY LEVEL <= LENGTH(REGEXP_REPLACE(DATA,'[^,]','')) - 1
    32  /
    NEW_STRING
    AAA
    BBB
    CC
    DDDD

  • Problem increasing dates with REGEXP_REPLACE and TO_DATE

    Hello all,
    i'm trying to increase dates in a string with a single statement, but i ran into the problem that Oracle doesn't interpret the regex backtrace operators when they are used in TO_DATE:
    SELECT
      REGEXP_REPLACE(
        'Test: 01.01.2001 Test: 02.02.2002',
        '([0-9]{2})\.([0-9]{2})\.([0-9]{4})',
        TO_CHAR(TO_DATE('\1\2\3', 'DDMMYYYY') + 1, 'DD.MM.YYYY')
    FROM DUALLeads to a ORA-01858: 01858, 00000, "a non-numeric character was found where a numeric was expected".
    However, using other functions on the backtrace operators like UPPER('\1') works like a charm. Is this a limitation of the TO_DATE function?
    Is there any possibility to replace the dates in a small, simple statement?
    Thanks in advance,
    -sd

    How should I show you an example, when it's simply
    not possible? I know I mixed up parameters and
    callbacks mistakenly and took the wrong approach.Ok. In your last post, you've added a question mark, so
    it did look as you weren't aware of the problem.
    However, I thought there was some possibility in
    Oracle regex to apply a callback function to
    regex-replacement like other languages have
    (preg_replace_callback in PHP for example) like:Interesting. Unfortunately PL/SQL is not PHP and there's
    (yet) no callback feature implemented.
    FUNCTION chg_date(
    p_string
    REGEXP_REPLACE_CALLBACK('Test: 2001', '[0-9]{4}',
    'chg_date')
    ...I too miss the possibility to extend the use of backtrace
    parameters, maybe in one of the future versions.
    C.

  • Using the REGEXP_REPLACE function

    I'm trying to get an understanding of the REGEXP_REPLACE function by going over this question and answer:
    Question: Some employees have entered the product_code incorrectly. It should appear as a series of characters followed by a slash followed by another series of characters.
    Instead of putting the single slash / that separates the two groups of characters, some employeess entered spaces, hyphens or both.
    Format all product codes by removing all the extra spaces and hyphens and replacing them with a single /
    Answer: REGEXP_REPLACE (product_code, '(( ) {1, } | (-)) {1, } ', '/')
    I am confused about the placement of brackets in the function as well as what the single pipe does?
    I am guessing it is the same as an OR operator but I'm not sure.
    I have read the oracle documentation on REGEXP_REPLACE but I'm still unsure.

    Hi,
    993451 wrote:
    I'm trying to get an understanding of the REGEXP_REPLACE function by going over this question and answer:
    Question: Some employees have entered the product_code incorrectly. It should appear as a series of characters followed by a slash followed by another series of characters.
    Instead of putting the single slash / that separates the two groups of characters, some employeess entered spaces, hyphens or both.
    Format all product codes by removing all the extra spaces and hyphens and replacing them with a single /
    Answer: REGEXP_REPLACE (product_code, '(( ) {1, } | (-)) {1, } ', '/')Are you sure that's the answer given? It doesn't work when I try it.
    It looks like there are extra spaces, and I suspect some of the round parentheses should really be square brackets, or are not really needed.
    As I understand the problem, this is one solution:
    REGEXP_REPLACE ( product_code
                , '[ -]+'
                ) The square brackets enclose a set of characters. In this case, the set contains 2 members: space and hyphen. The + sign means that we are looking for 1 or more characters that are in the set.
    I am confused about the placement of brackets in the function as well as what the single pipe does?
    I am guessing it is the same as an OR operator but I'm not sure.Yes, the vertical pipe means "OR".
    I have read the oracle documentation on REGEXP_REPLACE but I'm still unsure.Yes, the Oracle documentation is designed as a reference, not a tutorial, and the parts about regular expressions are not the best the Oracle has published.
    Try these sites:
    http://www.sqlsnippets.com/en/topic-10759.html
    http://www.dba-oracle.com/t_regular_expressions.htm
    Introduction to regular expressions ... last part.

  • Help in using  regexp_replace function.

    Hi everyone,
    i have a string something like this..
    varchar2(100) := 'SUBF1.AAAAAAAAAAAAA.SUBF1.BBBBBBBBBB.SUBF1'
    i want to replace the FIRST OCCURANCE of SUBF1 with some other string.
    EX:
    For the above string if i replace the FIRST OCCURANCE of SUBF1 with 'Hi' the output gonna be like this
    OUTPUT : 'Hi.AAAAAAAAAAAAA.SUBF1.BBBBBBBBBB.SUBF1'
    Sorry if this question had asked previously in this FORUM.
    Thanks in advance..
    phani

    test@ora>
    test@ora>
    test@ora> --
    test@ora> with t as (
      2    select 'SUBF1.AAAAAAAAAAAAA.SUBF1.BBBBBBBBBB.SUBF1' as x from dual)
      3  --
      4  select x,
      5         regexp_replace(x,'SUBF1','Hi',1,1) as modx
      6  from t;
    X                                          MODX
    SUBF1.AAAAAAAAAAAAA.SUBF1.BBBBBBBBBB.SUBF1 Hi.AAAAAAAAAAAAA.SUBF1.BBBBBBBBBB.SUBF1
    1 row selected.
    test@ora>
    test@ora>isotope

  • TRIM and regexp_Replace combined

    Hi there,
    a beginner question:
    I go the following string:
    :TEST:TEST2:
    I dont want to see leading and trailing : so i do
    Select trim (both ':' from ':TEST:TEST2:') from dual
    Now I also want to regexp_replace the ':' by a ','
    The solution should look like (Test,Test2)
    What to do now? Thx in advance [Oracle 11g]

    Hi,
    when you put some code or output please enclose it between two lines starting with {noformat}{noformat}
    i.e.:
    {noformat}{noformat}
    SELECT ...
    {noformat}{noformat}
    What you want to do cannot be done with static SQL.
    This code:Select * from testtable where Value in
    (select '('||
    ''''||
    replace(
    trim ( both ':' from ':TEST1:TEST2:')
    ||''''||')' r
    from dual);
    correspond to something like this:Select * from testtable where Value in
    ('(''TEST1'',''TEST2'')');
    So you are not actually checking if your value is in TEST1 or TEST2 but if your value correspond to a literal like "('TEST1','TEST2')" as a whole string.
    A solution could be found using dynamic SQL but don't know if it is really worth.
    Regards.
    Al                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • REGEXP_REPLACE - replace '\n''s inside a xml string

    I have this xml string and i need to replace the '\n' for one # but only the \n's inside the tag's not the first \n how do that with REGEXP_REPLACE?
    <?xml version="1.0" encoding="UTF-8"?>\n
    <ipb>
    <address>Rua são Joao\n
    Bragança
    </address>
    <calendar>
    1º Semestre:\n
    Início: 21/09/2009\n
    Fim: 19/02/2010\n
    Pausa Natal: de 21/12/2009 a 03/01/2010\n
    \n
    2º Semestre:\n
    Início: 22/02/2010\n
    Fim: 16/07/2010\n
    </calendar>

    Well, i'm no regular expression master, but no one's responded so i'll venture an answer (not using regular expression though).
    ME_XE?with data as
    select
    '<?xml version="1.0" encoding="UTF-8"?>\n
    <ipb>
    <address>Rua são Joao\n
    Bragança
    </address>
    <calendar>
    1º Semestre:\n
    Início: 21/09/2009\n
    Fim: 19/02/2010\n
    Pausa Natal: de 21/12/2009 a 03/01/2010\n
    \n
    2º Semestre:\n
    Início: 22/02/2010\n
    Fim: 16/07/2010\n
    </calendar>' as col1 from dual
    select
      replace(replace(replace(col1, '>\n', '~*~'), '\n', NULL), '~*~', '>\n') as new_col1
    from data;
    NEW_COL1
    <?xml version="1.0" encoding="UTF-8"?>\n
    <ipb>
    <address>Rua s??o Joao
    Bragan??a
    </address>
    <calendar>
    1?? Semestre:
    In??cio: 21/09/2009
    Fim: 19/02/2010
    Pausa Natal: de 21/12/2009 a 03/01/2010
    2?? Semestre:
    In??cio: 22/02/2010
    Fim: 16/07/2010
    </calendar>
    1 row selected.
    Elapsed: 00:00:00.17
    ME_XE?Just used the regular replace to decode the instances of \n you want to keep (using a string you're not likely to find in your source data) and then replaced all the \n's with null, then put back the /n replacing the string we subbed in before.
    If Michaels is around, maybe you'll get a flashy XML answer to your question ... sorry, but i'm not that much flash :)

  • How to used REGEXP_REPLACE  for replace part of string ?

    hi
    How can i replace part of string as following , i want to replace space in date by "-"
    SELECT
    REGEXP_REPLACE(upper('Daivd bought stuff by 2000 USD on 12 Sep 2012 from KL and left kl on 20 Sep 2012'),
    '[0-9]{1,2}[^0-9](JAN|FEB|MAR|APR|JUN|JUL|AUG|SEP|OCT|NOV|DEC)[^0-9][0-9]{4}',
    ' ','-') "REGEXP_REPLACE"
    FROM DUAL;
    the output will be like this
    Daivd bought stuff by 2000 USD on 12-Sep-2012 from KL and left kl on 20-Sep-2012
    regards

    I thought the questions is answered.
    Your code will not work, because the alternate expression applies only to the four digit year and the month.
    If you want to recognize both date formats with one expressions, you have to group the complete expressions.
    The disadvantage of this would be, that the backreferences would not work in the same way because you would have more groups.
    I advice to use two separate regular expressions for this task.
    Take a look at the following example if you simply want to fill the gaps with -:
    with yourtable as
      select 'Daivd bought stuff by 2000 USD on 12 Sep 2012 from KL and left kl on 20 Sep 2012' text from dual union all
      select 'Daivd bought stuff by 2000 USD on Sep, 20 2012 from KL and left kl on Sep, 20 2012' text from dual 
    SELECT
    REGEXP_REPLACE(
    REGEXP_REPLACE(text,
    '([0-9]{1,2}) (JAN|FEB|MAR|APR|JUN|JUL|AUG|SEP|OCT|NOV|DEC) ([0-9]{4})','\1-\2-\3',1,0,'i'),
    '(JAN|FEB|MAR|APR|JUN|JUL|AUG|SEP|OCT|NOV|DEC), ([0-9]{1,2}) ([0-9]{4})','\1-\2-\3',1,0,'i') regexp_replace
    FROM yourtable;If you want same output-format for both date formats you could use this:
    with yourtable as
      select 'Daivd bought stuff by 2000 USD on 12 Sep 2012 from KL and left kl on 20 Sep 2012' text from dual union all
      select 'Daivd bought stuff by 2000 USD on Sep, 20 2012 from KL and left kl on Sep, 20 2012' text from dual 
    SELECT
    REGEXP_REPLACE(
    REGEXP_REPLACE(text,
    '([0-9]{1,2}) (JAN|FEB|MAR|APR|JUN|JUL|AUG|SEP|OCT|NOV|DEC) ([0-9]{4})','\1-\2-\3',1,0,'i'),
    '(JAN|FEB|MAR|APR|JUN|JUL|AUG|SEP|OCT|NOV|DEC), ([0-9]{1,2}) ([0-9]{4})','\2-\1-\3',1,0,'i') regexp_replace
    FROM yourtable;Edited by: hm on 25.09.2012 22:00

  • Question about correct use of WM_CONCAT

    Good morning,
    I'm trying to accomplish the following:
    starting with this
         ENAME
         ADAMS
         ALLEN
         BLAKE
    ...and ending with this
         OLD_NAME   NEW_NAME
         ADAMS      AADMS
         ALLEN      AELLN
         BLAKE      ABEKL
    ...basically, alphabetically sorting the characters inside each name. I have an intermediate step that looks promising
    select e.ename oldname, substr(e.ename, iter.pos, 1) newcharpos
      from emp e,
           (select rownum pos from emp) iter
    where iter.pos <= length(e.ename)
    order by e.ename, substr(e.ename, iter.pos, 1);The above yields
    OLDNAME    NEWCHARPOS
    ADAMS      A
    ADAMS      A
    ADAMS      D
    ADAMS      M
    ADAMS      S
    ALLEN      A
    ALLEN      E
    ALLEN      L
    ALLEN      L
    ALLEN      N
    BLAKE      A
    BLAKE      B
    BLAKE      E
    BLAKE      K
    BLAKE      L
    ...the individual characters are in the right sequence, I figured all I had to do was to use WM_CONCAT (and replace the comma it inserts with the empty string) and I'd be done. I figured this would do it: (replace of comma left out for clarity)
    select oldname,
           wm_concat(newcharpos) newname
      from (
            select e.ename oldname, substr(e.ename, iter.pos, 1) newcharpos
              from emp e,
                   (select rownum pos from emp) iter
             where iter.pos <= length(e.ename)
             order by e.ename, substr(e.ename, iter.pos, 1)
      group by oldname;but the sequence of newcharpos gets messed up in the process and, instead of the expected result, I get this:
    OLDNAME    NEWNAME
    ADAMS      A,S,M,D,A
    ALLEN      A,N,L,L,E
    BLAKE      A,L,K,E,B
    ...My question is, how do I structure the last query so the character order stays as calculated in the inner query ?
    Thank you for your help,
    John.

    Or
    SQL> select   oldname,
           wm_concat(newcharpos) keep (dense_rank last order by null)  newname
      from (
            select e.ename oldname, substr(e.ename, iter.pos, 1) newcharpos
              from emp e,
                   (select rownum pos from emp) iter
             where iter.pos <= length(e.ename)
             order by e.ename, substr(e.ename, iter.pos, 1)
      group by oldname
    OLDNAME    NEWNAME                      
    ADAMS      A,A,D,M,S                    
    ALLEN      A,E,L,L,N                    
    BLAKE      A,B,E,K,L                    
    CLARK      A,C,K,L,R                    
    FORD       D,F,O,R                      
    JAMES      A,E,J,M,S                    
    JONES      E,J,N,O,S                    
    KING       G,I,K,N                      
    MARTIN     A,I,M,N,R,T                  
    MILLER     E,I,L,L,M,R                  
    SCOTT      C,O,S,T,T                    
    SMITH      H,I,M,S,T                    
    TURNER     E,N,R,R,T,U                  
    WARD       A,D,R,W                      
    14 rows selected.Or (11gR2)
    SQL> select ename oldname, column_value newname
      from emp,
           xmltable(('string-join(for $i in (' || rtrim(regexp_replace(ename, '(.)', '"\1",'),',') || ') order by $i return $i, "")'))
    OLDNAME    NEWNAME                      
    SMITH      HIMST                        
    ALLEN      AELLN                        
    WARD       ADRW                         
    JONES      EJNOS                        
    MARTIN     AIMNRT                       
    BLAKE      ABEKL                        
    CLARK      ACKLR                        
    SCOTT      COSTT                        
    KING       GIKN                         
    TURNER     ENRRTU                       
    ADAMS      AADMS                        
    JAMES      AEJMS                        
    FORD       DFOR                         
    MILLER     EILLMR                       
    14 rows selected.

  • Questions on Print Quote report

    Hi,
    I'm fairly new to Oracle Quoting and trying to get familiar with it. I have a few questions and would appreciate if anyone answers them
    1) We have a requirement to customize the Print Quote report. I searched these forums and found that this report can be defined either as a XML Publisher report or an Oracle Reports report depending on a profile option. Can you please let me know what the name of the profile option is?
    2) When I select the 'Print Quote' option from the Actions drop down in the quoting page and click Submit I get the report printed and see the following URL in my browser.
    http://<host>:<port>/dev60cgi/rwcgi60?PROJ03_APPS+report=/proj3/app/appltop/aso/11.5.0/reports/US/ASOPQTEL.rdf+DESTYPE=CACHE+P_TCK_ID=23731428+P_EXECUTABLE=N+P_SHOW_CHARGES=N+P_SHOW_CATG_TOT=N+P_SHOW_PRICE_ADJ=Y+P_SESSION_ID=c-RAuP8LOvdnv30grRzKqUQs:S+P_SHOW_HDR_ATTACH=N+P_SHOW_LINE_ATTACH=N+P_SHOW_HDR_SALESUPP=N+P_SHOW_LN_SALESUPP=N+TOLERANCE=0+DESFORMAT=RTF+DESNAME=Quote.rtf
    Does it mean that the profile in our case is set to call the rdf since it has reference to ASOPQTEL.rdf in the above url?
    3) When you click on submit button do we have something like this in the jsp code: On click call ASOPQTEL.rdf. Is the report called using a concurrent program? I want to know how the report is getting invoked?
    4) If we want to customize the jsp pages can you please let me know the steps involved in making the customizations and testing them.
    Thanks and Appreciate your patience
    -PC

    1) We have a requirement to customize the Print Quote report. I searched these forums and found that this report can be defined either as a XML Publisher report or an Oracle Reports report depending on a profile option. Can you please let me know what the name of the profile option is?
    I think I posted it in one of the threads2) When I select the 'Print Quote' option from the Actions drop down in the quoting page and click Submit I get the report printed and see the following URL in my browser.
    http://<host>:<port>/dev60cgi/rwcgi60?PROJ03_APPS+report=/proj3/app/appltop/aso/11.5.0/reports/US/ASOPQTEL.rdf+DESTYPE=CACHE+P_TCK_ID=23731428+P_EXECUTABLE=N+P_SHOW_CHARGES=N+P_SHOW_CATG_TOT=N+P_SHOW_PRICE_ADJ=Y+P_SESSION_ID=c-RAuP8LOvdnv30grRzKqUQs:S+P_SHOW_HDR_ATTACH=N+P_SHOW_LINE_ATTACH=N+P_SHOW_HDR_SALESUPP=N+P_SHOW_LN_SALESUPP=N+TOLERANCE=0+DESFORMAT=RTF+DESNAME=Quote.rtf
    Does it mean that the profile in our case is set to call the rdf since it has reference to ASOPQTEL.rdf in the above url?
    Yes, your understanding is correct.3) When you click on submit button do we have something like this in the jsp code: On click call ASOPQTEL.rdf. Is the report called using a concurrent program? I want to know how the report is getting invoked?
    No, there is no conc program getting called, you can directly call a report in a browser window, Oracle reports server will execute the report and send the HTTP response to the browser.4) If we want to customize the jsp pages can you please let me know the steps involved in making the customizations and testing them.
    This is detailed in many threads.Thanks
    Tapash

  • Satellite P300D-10v - Question about warranty

    HI EVERYBODY
    I have these overheating problems with my laptop Satellite P300D-10v.
    I did everything I could do to fix it without any success..
    I get the latest update of the bios from Toshiba. I cleaned my lap with compressed air first and then disassembled it all and cleaned it better.(it was really clean insight though...)
    BUT unfortunately the problem still exists...
    So i made a research on the internet and I found out that most of Toshiba owners have the same exactly problem with their laptop.
    Well i guess this is a Toshiba bug for many years now.
    Its a really nice lap, cool sound (the best in laptop ever) BUT......
    So I wanted to make a question. As i am still under warranty, can i return this laptop and get my money back or change it with a different one????
    If any body knows PLS let me know.
    chears
    Thanks in advance

    Hi
    I have already found you other threads.
    Regarding the warranty question;
    If there is something wrong with the hardware then the ASP in your country should be able to help you.
    The warranty should cover every reparation or replacement.
    But I read that you have disasembled the laptop at your own hand... hmmm if you have disasembled the notebook then your warrany is not valid anymore :(
    I think this should be clear for you that you can lose the warrany if you disasemble the laptop!
    By the way: you have to speak with the notebook dealer where you have purchased this notebook if you want to return the notebook
    The Toshiba ASP can repair and fix the notebook but you will not get money from ASP.
    Greets

Maybe you are looking for

  • Error opening URL

    Hello, I am working on a project in Flash CS 3 Profesional but I am using Actionscript 2.0.  I am using Adobe's Flash 8 Actionscript:  Training from the Source book.  I am attempting to open a file from a URL on my site and I am getting an error sayi

  • Logic Pro Wont Start

    Hello, I just downloaded the new OSX Lion for my Macbook Pro. I recently bought the Zoom R24 and wanted to use that device as a audio interface, but come to find out there isnt a driver thats compatiable between the zoom R24 and the new Osx Lion. So

  • Timestamp error in one-to-one load

    Hi, I'm facing a issue while loading data from oracle view to sql table.Its simple one to one load.SRC-SQ-TGT Error:Message Code : WRT_8229Message : Database errors occurred: FnName: Execute -- [Informatica][ODBC SQL Server Wire Protocol driver]Times

  • EM12c Upgrade failing at OMS  Configuration

    I'm in the process of upgrading and migrating from EM 10.2.0.5 on AIX 6.1 to EM12c on RHEL 6.2 via the 2-System Upgrade method. I've been following the steps in the MOS Note "EM 12c: Upgrading to Enterprise Manager Cloud Control 12.1.0.1 on Linux x86

  • Failed to Reload 4.5 Operating System

    Hello, I wiped out my blackberry curve 8310 and am having a problem to reload the OS. It show a white screen with an error 507. Whenever I use the application loader it brings this message:-  The blackberry desktop software does not have Blackberry D