Regular expressions in 10g

Can any body provide good Oracle 10g regular expression tutorial with example link ?

Here below links from nice post entries from cd :
Introduction to regular expressions ...
Introduction to regular expressions ... continued.
Nicolas.

Similar Messages

  • Regular Expression in 8i

    Hi,
    I have trouble in regular expressions.. I am trying to do something like this:
    SELECT PRT_DESC FROM tablename
    WHERE SUBSTR(PRT_DESC,5,5) LIKE '[0-9][0-9][0-9][0-9][0-9]'
    Returns 0 rows which is incorrect..
    Can anyone help me out??
    Thanks

    Oracle didn't support regular expressions until 10g. In prior versions, there is an owa_pattern package that may be useful to you here.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Regular Expressions in Discoverer 10g

    I have figured out how to use LIKE to do some basic sorting, but I would like to be able to use the regular expressions that are supposed to be built into Oracle 10g. However, I keep getting the following error message when I try to use REGEXP_INSTR, REGEXP_LIKE, REGEXP_REPLACE, and REGEXP_SUBSTR:
    Function REGEXP_LIKE has not been registered with the EUL.
    What does this mean? Do I have to get permission from the Discoverer admin to use regular expresssions in the end user layer?
    Thanks,
    Rachel

    Rachel,
    This means that these functions are not available in Discoverer.
    All available function are listed in Edit Calculation window of Calculation wizard - if you click on Functions radio button and click on '+' next to All Functions then you can see all database functions available to Discoverer and regular expression functions are not listed there.
    However, you should be able to create your own database functions using regular expressions and then register them in Discoverer. All you would do is create a function ( a wrapper) around actual regular expression functions you want to use, compile the functions in database and then register in Discoverer Admin.
    e.g.,
    create or replace function my_own_reg_replace (parameter1, paramete2 etc)
    return varchar2
    my_result varchar2(2000);
    begin
    my_result := regexp_replace(paramete1, parameter2 etc);
    return my_result
    end;
    Hope this helps.,
    Raman
    Hope this helps.

  • Introduction to regular expressions ...

    I'm well aware that there are already some articles on that topic, some people asked me to share some of my knowledge on this topic. Please take a look at this first part and let me know if you find this useful. If yes, I'm going to continue on writing more parts using more and more complicated expressions - if you have questions or problems that you think could be solved through regular expression, please post them.
    Introduction
    Oracle has always provided some character/string functions in its PL/SQL command set, such as SUBSTR, REPLACE or TRANSLATE. With 10g, Oracle finally gave us, the users, the developers and of course the DBAs regular expressions. However, regular expressions, due to their sometimes cryptic rules, seem to be overlooked quite often, despite the existence of some very interesing use cases. Beeing one of the advocates of regular expression, I thought I'll give the interested audience an introduction to these new functions in several installments.
    Having fun with regular expressions - Part 1
    Oracle offers the use of regular expression through several functions: REGEXP_INSTR, REGEXP_SUBSTR, REGEXP_REPLACE and REGEXP_LIKE. The second part of each function already gives away its purpose: INSTR for finding a position inside a string, SUBSTR for extracting a part of a string, REPLACE for replacing parts of a string. REGEXP_LIKE is a special case since it could be compared to the LIKE operator and is therefore usually used in comparisons like IF statements or WHERE clauses.
    Regular expressions excel, in my opinion, in search and extraction of strings, using that for finding or replacing certain strings or check for certain formatting criterias. They're not very good at formatting strings itself, except for some special cases I'm going to demonstrate.
    If you're not familiar with regular expression, you should take a look at the definition in Oracle's user guide Using Regular Expressions With Oracle Database, and please note that there have been some changes and advancements in 10g2. I'll provide examples, that should work on both versions.
    Some of you probably already encountered this problem: checking a number inside a string, because, for whatever reason, a column was defined as VARCHAR2 and not as NUMBER as one would have expected.
    Let's check for all rows where column col1 does NOT include an unsigned integer. I'll use this SELECT for demonstrating different values and search patterns:
    WITH t AS (SELECT '456' col1
                 FROM dual
                UNION
               SELECT '123x'
                 FROM dual
                UNION  
               SELECT 'x123'
                 FROM dual
                UNION 
               SELECT 'y'
                 FROM dual
                UNION 
               SELECT '+789'
                 FROM dual
                UNION 
               SELECT '-789'
                 FROM dual
                UNION 
               SELECT '159-'
                 FROM dual
                UNION 
               SELECT '-1-'
                 FROM dual
    SELECT t.col1
      FROM t
    WHERE NOT REGEXP_LIKE(t.col1, '^[0-9]+$')
    ;Let's take a look at the 2nd argument of this REGEXP function: '^[0-9]+$'. Translated it would mean: start at the beginning of the string, check if there's one or more characters in the range between '0' and '9' (also called a matching character list) until the end of this string. "^", "[", "]", "+", "$" are all Metacharacters.
    To understand regular expressions, you have to "think" in regular expressions. Each regular expression tries to "fit" an available string into its pattern and returns a result beeing successful or not, depending on the function. The "art" of using regular expressions is to construct the right search pattern for a certain task. Using functions like TRANSLATE or REPLACE did already teach you using search patterns, regular expressions are just an extension to this paradigma. Another side note: most of the search patterns are placeholders for single characters, not strings.
    I'll take this example a bit further. What would happen if we would remove the "$" in our example? "$" means: (until the) end of a string. Without this, this expression would only search digits from the beginning until it encounters either another character or the end of the string. So this time, '123x' would be removed from the SELECTION since it does fit into the pattern.
    Another change: we will keep the "$" but remove the "^". This character has several meanings, but in this case it declares: (start from the) beginning of a string. Without it, the function will search for a part of a string that has only digits until the end of the searched string. 'x123' would now be removed from our selection.
    Now there's a question: what happens if I remove both, "^" and "$"? Well, just think about it. We now ask to find any string that contains at least one or more digits, so both '123x' and 'x123' will not show up in the result.
    So what if I want to look for signed integer, since "+" is also used for a search expression. Escaping is the name of the game. We'll just use '^\+[0-9]+$' Did you notice the "\" before the first "+"? This is now a search pattern for the plus sign.
    Should signed integers include negative numbers as well? Of course they should, and I'll once again use a matching character list. In this list, I don't need to do escaping, although it is possible. The result string would now look like this: '^[+-]?[0-9]+$'. Did you notice the "?"? This is another metacharacter that changes the placeholder for plus and minus to an optional placeholder, which means: if there's a "+" or "-", that's ok, if there's none, that's also ok. Only if there's a different character, then again the search pattern will fail.
    Addendum: From this on, I found a mistake in my examples. If you would have tested my old examples with test data that would have included multiple signs strings, like "--", "-+", "++", they would have been filtered by the SELECT statement. I mistakenly used the "*" instead of the "?" operator. The reason why this is a bad idea, can also be found in the user guide: the "*" meta character is defined as 0 to multiple occurrences.
    Looking at the values, one could ask the question: what about the integers with a trailing sign? Quite simple, right? Let's just add another '[+-] and the search pattern would look like this: '^[+-]?[0-9]+[+-]?$'.
    Wait a minute, what happened to the row with the column value "-1-"?
    You probably already guessed it: the new pattern qualifies this one also as a valid string. I could now split this pattern into several conditions combined through a logical OR, but there's something even better: a logical OR inside the regular expression. It's symbol is "|", the pipe sign.
    Changing the search pattern again to something like this '^[+-]?[0-9]+$|^[0-9]+[+-]?$' [1] would return now the "-1-" value. Do I have to duplicate the same elements like "^" and "$", what about more complicated, repeating elements in future examples? That's where subexpressions/grouping comes into play. If I want only certain parts of the search pattern using an OR operator, we can put those inside round brackets. '^([+-]?[0-9]+|[0-9]+[+-]?)$' serves the same purpose and allows for further checks without duplicating the whole pattern.
    Now looking for integers is nice, but what about decimal numbers? Those may be a bit more complicated, but all I have to do is again to think in (meta) characters. I'll just use an example where the decimal point is represented by ".", which again needs escaping, since it's also the place holder in regular expressions for "any character".
    Valid decimals in my example would be ".0", "0.0", "0.", "0" (integer of course) but not ".". If you want, you can test it with the TO_NUMBER function. Finding such an unsigned decimal number could then be formulated like this: from the beginning of a string we will either allow a decimal point plus any number of digits OR at least one digits plus an optional decimal point followed by optional any number of digits. Think about it for a minute, how would you formulate such a search pattern?
    Compare your solution to this one:
    '^(\.[0-9]+|[0-9]+(\.[0-9]*)?)$'
    Addendum: Here I have to use both "?" and "*" to make sure, that I can have 0 to many digits after the decimal point, but only 0 to 1 occurrence of this substrings. Otherwise, strings like "1.9.9.9" would be possible, if I would write it like this:
    '^(\.[0-9]+|[0-9]+(\.[0-9]*)*)$'Some of you now might say: Hey, what about signed decimal numbers? You could of course combine all the ideas so far and you will end up with a very long and almost unreadable search pattern, or you start combining several regular expression functions. Think about it: Why put all the search patterns into one function? Why not split those into several steps like "check for a valid decimal" and "check for sign".
    I'll just use another SELECT to show what I want to do:
    WITH t AS (SELECT '0' col1
                 FROM dual
                UNION
               SELECT '0.' 
                 FROM dual
                UNION
               SELECT '.0' 
                 FROM dual
                UNION
               SELECT '0.0' 
                 FROM dual
                UNION
               SELECT '-1.0' 
                 FROM dual
                UNION
               SELECT '.1-' 
                 FROM dual
                UNION
               SELECT '.' 
                 FROM dual
                UNION
               SELECT '-1.1-' 
                 FROM dual
    SELECT t.*
      FROM t
    ;From this select, the only rows I need to find are those with the column values "." and "-1.1-". I'll start this with a check for valid signs. Since I want to combine this with the check for valid decimals, I'll first try to extract a substring with valid signs through the REGEXP_SUBSTR function:
    NVL(REGEXP_SUBSTR(t.col1, '^([+-]?[^+-]+|[^+-]+[+-]?)$'), ' ')Remember the OR operator and the matching character collections? But several "^"? Some of the meta characters inside a search pattern can have different meanings, depending on their positions and combination with other meta characters. In this case, the pattern translates into: from the beginning of the string search for "+" or "-" followed by at least another character that is not "+" or "-". The second pattern after the "|" OR operator does the same for a sign at the end of the string.
    This only checks for a sign but not if there also only digits and a decimal point inside the string. If the search string fails, for example when we have more than one sign like in the "-1.1-", the function returns NULL. NULL and LIKE don't go together very well, so we'll just add NVL with a default value that tells the LIKE to ignore this string, in this case a space.
    All we have to do now is to combine the check for the sign and the check for a valid decimal number, but don't forget an option for the signs at the beginning or end of the string, otherwise your second check will fail on the signed decimals. Are you ready?
    Does your solution look a bit like this?
    WHERE NOT REGEXP_LIKE(NVL(REGEXP_SUBSTR(t.col1,
                               '^([+-]?[^+-]+|[^+-]+[+-]?)$'),
                           '^[+-]?(\.[0-9]+|[0-9]+(\.[0-9]*)?)[+-]?$'
                          )Now the optional sign checks in the REGEXP_LIKE argument can be added to both ends, since the SUBSTR won't allow any string with signs on both ends. Thinking in regular expression again.
    Continued in Introduction to regular expressions ... continued.
    C.
    Fixed some embarrassing typos ... and mistakes.
    cd

    Excellent write up CD. Very nice indeed. Hopefully you'll be completing parts 2 and 3 some time soon. And with any luck, your article will encourage others to do the same....I know there's a few I'd like to see and a few I'd like to have a go at writing too :-)

  • Regular expressions in Rename Wizard Utility

    Hi guys,
    Does anyone know how to use regular expressions (and it possible) in OBIEE's internal "Rename Wizard" utility. For example, I have the following columns:
    % Change Variance ColumnName1
    % Change Variance ColumnName2
    % Change Variance ColumnName3
    and I want them to be
    Variance ColumnName1 % Change
    Variance ColumnName2 % Change
    Variance ColumnName3 % Change
    Is there another way to do this except than by hand? Your help is appreciated.

    user447618,
    Regular Expressions were first introduced in SQL and PL/SQL as of Oracle Database 10g. What version of the database are you running?
    Sergio

  • Regular expression fro date time format

    Hi
    im trying to use regexp_like() function in my where clause as
    select 1 from dual where REGEXP_LIKE(''31/12/2003 11:59:59 PM',regular expr pattern)
    I tried this pattern using the following regular expresion which i found on a web site. but this didnt work.
    '^(?=\d)(?:(?:31(?!.(?:0?[2469]|11))|(?:30|29)(?!.0?2)|29(?=.0?2.(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(?:\x20|$))|(?:2[0-8]|1\d|0?[1-9]))(\/)(?:1[012]|0?[1-9])\1(?:1[6-9]|[2-9]\d)?\d\d(?:(?=\x20\d)\x20|$))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\x20[AP]M)?)|([01]\d|2[0-3])(:[0-5]\d){1,2})?$'
    can some one suggest me an alternative regular expression for this.
    P.S : i donot want to use to_char/ to_date functions.
    Regards
    Vibhuti

    Hi elic
    I tried with your suggestion yet it didnt work. This is my query
    select 1 from dual where regexp_like('03/02/2000 02:59:59 AM','^(?=[0-9])(?:(?:31(?!.(?:0?[2469]|11))|(?:30|29)(?!.0?2)|29(?=.0?2.(?:(?:(?:1[6-9]|[2-9][0-9])?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(?: |$))|(?:2[0-8]|1[0-9]|0?[1-9]))(\/)(?:1[012]|0?[1-9])\1(?:1[6-9]|[2-9][0-9])?[0-9][0-9](?:(?= [0-9]) |$))?(((0?[1-9]|1[012])(:[0-5][0-9]){0,2}( [AP]M)?)|([01][0-9]|2[0-3])(:[0-5][0-9]){1,2})?$')
    this should return 1 as output. but its not returning any thing. Im currently working on 10g R2 database. Please help me out, its very critical. Im trying to learn regualr expressions but im unable to crack this code.
    Regards
    Vibhuti

  • Regular Expression and PL/SQL help

    I am using Oracle 9i, does 9i support regular expression? What functions are there?
    My problem is the birth_date column in my database comes from teleform ( a scan program that reads what people wrote on paper), so the format is all jacked up.... 50% of them are 01/01/1981, 10% are 5/14/1995, 10% are 12/5/1993, 10% are 1/1/1983, 10% are 24-JUL-98. I have never really used regular expression and pl/sql, can anybody help me convert all of them to 01/01/1998?
    Does Oralce 9i support regular expression? What can I do if oralce 9i does not support regular expression? Thank you very much in advance.

    9i doesn't support regular expressions (at least not in the 10g regular expressions sense. There is an OWA_PATTERN_MATCH package that has some facilities for regular expressions). But it doesn't look like this is a regular expressions problem.
    Instead, this is probably a case where you need to
    - enumerate the format masks you want to try
    - determine the order you want to try them
    - write a small function that tries each format mask in succession until one matches.
    Of course, there is no guarantee that you'll ever be able to convert the data to the date that the user intended because some values will be ambiguous. For example, 01/02/03 could mean Feb 1, 2003 or Jan 2, 2003 or Feb 3, 2001 depending on the person who entered the data.
    Assuming you can define the order, your function would just try each format mask in turn until one generated a valid date, i.e.
    BEGIN
      BEGIN
        l_date := TO_DATE( p_string_value, format_mask_1 );
        RETURN l_date;
      EXCEPTION
        WHEN OTHERS THEN
          NULL;
      END;
      BEGIN
        l_date := TO_DATE( p_string_value, format_mask_2 );
        RETURN l_date;
      EXCEPTION
        WHEN OTHERS THEN
          NULL;
      END;
      BEGIN
        l_date := TO_DATE( p_string_value, format_mask_3 );
        RETURN l_date;
      EXCEPTION
        WHEN OTHERS THEN
          NULL;
      END;
      BEGIN
        l_date := TO_DATE( p_string_value, format_mask_N );
        RETURN l_date;
      EXCEPTION
        WHEN OTHERS THEN
          NULL;
      END;
      RETURN NULL;
    END;Justin

  • Functionality equivalent to Regular Expressions

    Hi,
    We have a old, very badly designed database(which by the way is the culprit of all the problems).
    There is a varchar2 column with values like -
    C500
    500FCG
    50-100
    MX
    ADW
    Y
    10-5
    500
    B1
    C500
    I am trying to retrieve only digits with no leading or trailing alphabets. But i still want numbers like 50-100.
    I know in 10g this could be easily done with regular expressions. But we are still using oracle 9i.
    Is it possible within the sql statement or is there any other way to do it(like using some perl programs calling from plsql).
    Any suggestions greatly appreciated.
    Thanks,
    Siri

    Sorry Mohana for not explaining my req clearly.
    Actually i was able to get the results by changing your query a little.
    Here is the query -
    select NVL(replace(translate(cov_limit, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ','*'),' '), cov_limit) as After, cov_limit as Before
    from test;
    SQL> /
    BEFORE
    C500
    500FCG
    50-100
    MX
    ADW
    Y
    10-5
    500
    B1
    C500
    1000
    AMD
    CAD
    MAD
    WAT
    FCG
    CG
    AD
    DW
    A
    A500
    AFTER
    500
    500
    50-100
    MX
    Y
    10-5
    500
    1
    500
    1000
    FCG
    CG
    DW
    *500
    Only thing i am not able to understand is why the alphabet 'A' is not getting replaced with blank.
    Thanks & Regards,
    Sree

  • ANN: New Regular Expressions Sample

    Hi,
    Regular expressions introduced in Oracle 10g Database is one of the most powerful ways of searching, manipulating and transforming text data.
    Check out this new [url http://www.oracle.com/technology/sample_code/tech/pl_sql/regexp/dnasample/readme.html]DNA Analysis Sample, that uses the regular expression APIs to identify certain enzyme patterns in a DNA Sequence.
    Also visit the [url http://www.oracle.com/technology/sample_code/tech/pl_sql/index.html]PL/SQL Sample Code page for more samples on PL/SQL.
    Thanks
    Shrinivas
    OTN Team

    This bunch of samples does not currently have one. We will look at it.
    Cheers,
    -- Rajesh

  • Regular expression...

    Hello,
    I'm trying to understand regular expressions in Oracle 10g. I have to say that I'm a little lost. Can anyone tell me how can I extract using REGEXP_SUBSTR function the text between the parentheses?
    Here is a sample code:
    WITH T1 AS (
    SELECT 1 A, 'My first name (Hello) is not so long...' B FROM DUAL
    UNION ALL
    SELECT 2, 'My second (World) name is shorter.' FROM DUAL
    UNION ALL
    SELECT 3, q'[(I'm) My third name is stupid.]' FROM DUAL
    UNION ALL
    SELECT 4, '[My forth name end with (a regexp)]' FROM DUAL
    SELECT B, REGEXP_SUBSTR(B, '\([[:alpha:]]+\)' FROM T1;As result, I want
    Hello
    World
    I'm
    a regexpThe result should not include the parentheses.
    I tried the previous code, but I have an exception:
    Paramètre IN ou OUT absent dans l'index :: 1Thanks for your help

    WITH T1 AS
      ( SELECT 1 A, 'My first name (Hello) is not so long...' B FROM DUAL
      UNION ALL
       SELECT 2, 'My second (World) name is shorter.' FROM DUAL
      UNION ALL
       SELECT 3, q'[(I'm) My third name is stupid.]' FROM DUAL
      UNION ALL
       SELECT 4, '[My forth name end with (a regexp)]' FROM DUAL
    SELECT B, REGEXP_replace(B, '.*\((.*)\).*','\1') FROM T1;Ravi Kumar

  • Regular expressions in oracle 10 g

    how to use regular expressions in oracle 10g forms

    May be forms related question better answered in forms forum.
    Forms

  • Regular expressions with multi character separator

    I have data like the
    where |`| is the separator for distinguishing two fields of data. I am having trouble writing a regular expression to display the data correctly.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> declare
      2  l_string varchar2 (200) :='123` 456 |`|789 10 here|`||223|`|5434|`}22|`|yes';
      3  v varchar2(40);
      4  begin
      5  v:=regexp_substr(l_string, '[^(|`|)]+', 1, 1);
      6  dbms_output.put_line(v);
      7  v:=regexp_substr(l_string, '[^(|`|)]+', 1, 2);
      8  dbms_output.put_line(v);
      9  v:=regexp_substr(l_string, '[^(|`|)]+', 1, 3);
    10  dbms_output.put_line(v);
    11  v:=regexp_substr(l_string, '[^(|`|)]+', 1, 4);
    12  dbms_output.put_line(v);
    13  v:=regexp_substr(l_string, '[^(|`|)]+', 1, 5);
    14  dbms_output.put_line(v);
    15  end;
    16  /
    123
    456
    789 10 here
    223
    5434I need it to display
    123` 456
    789 10 here
    |223
    5434|`}22
    yesI am not sure how to handle multi character separators in data using reg expressions
    Edited by: Clearance 6`- 8`` on Apr 1, 2011 3:35 PM
    Edited by: Clearance 6`- 8`` on Apr 1, 2011 3:37 PM

    Hi,
    Actually, using non-greedy matching, you can do what you want with regular expressions:
    VARIABLE     l_string     VARCHAR2 (100)
    EXEC  :l_string := '123` 456 |`|789 10 here|`||223|`|5434|`}22|`|yes'
    SELECT     LEVEL
    ,     REPLACE ( REGEXP_SUBSTR ( '|`|' || REPLACE ( :l_string
                                     , '|`|'
                                      , '|`||`|'
                                     ) || '|`|'
                        , '\|`\|.*?\|`\|'
                        , 1
                        , LEVEL
               , '|`|'
               )     AS ITEM
    FROM     dual
    CONNECT BY     LEVEL     <= 7
    ;Output:
    LEVEL ITEM
        1 123` 456
        2 789 10 here
        3 |223
        4 5434|`}22
        5 yes
        6
        7Here's how it works:
    The pattern
    ~.*?~is non-greedy ; it matches the smallest possible string that begins and ends with a '~'. So
    REGEXP_SUBSTR ('~SHALL~I~COMPARE~THEE~', '~.*?~', 1, 1) returns '~SHALL~'. However,
    REGEXP_SUBSTR ('~SHALL~I~COMPARE~THEE~', '~.*?~', 1, 2) returns '~COMPARE~'. Why not '~I~'? Because the '~' between 'SHALL' and 'I' was part of the 1st pattern, so it can't be part of the 2nd pattern. So the first thing we have to do is double the delimiters; that's what the inner REPLACE does. The we add delimiters to the beginning and end of the list. Once we've done prepared the string like that, we can use the non-greedy REGEXP_SUBSTR to bring back the delimited items, with a delimiter at either end. We don't want those delimiters, so the outer REPLACE removes them.
    I'm not sure this is any better than Sri's solution.

  • Using Regular Expressions in 1.6

    I'm a new HTML DB user. I've been through 1.5 training, but I'm now trying to find my way thru 1.6. In 1.5 I could select Regular Expression as a validation type, within the validation wizard. How do I "tie" a Regular Expression validation to a field within 1.6?

    user447618,
    Regular Expressions were first introduced in SQL and PL/SQL as of Oracle Database 10g. What version of the database are you running?
    Sergio

  • Regular Expression/Replace - Oracle 7.3

    Hi!
    I am trying the regular expression SQL functions of 10g to Oracle 7.3 and it seems the older version does not cover this feature yet.
    "Aaaa,Bbbb" --> "Aaaa, Bbbb"
    REPLACE *",[0-9A-Za-z]"* WITH *", "*
    The string pattern is to look for comma-punctuations that is not followed immediately by whitespacess so I can replace this with a comma followed by a whitespace.
    Any workaround for this?

    Hi,
    Welcome to the forum!
    kitsune wrote:
    Hi!
    I am trying the regular expression SQL functions of 10g to Oracle 7.3 and it seems the older version does not cover this feature yet.You're right; regular expressions only work in Oracle 10.1 and higher.
    >
    >
    "Aaaa,Bbbb" --> "Aaaa, Bbbb"
    REPLACE *",[0-9A-Za-z]"* WITH *", "*
    The string pattern is to look for comma-punctuations that is not followed immediately by whitespacess so I can replace this with a comma followed by a whitespace.
    Any workaround for this?You're best bet in Oracle 7.3 would be a user-defined function. That's a very old version; don't expect much.
    Do you know anything else about the string? For example, is there some character (say ~) that never occurs in the string? Will there ever be two (or more) whitespace characters after punctuation? What characters do you consider to be whitespace? Which are punctuation? Depending on the answers, you might be able to do something with nested REPLACE and/or TRANSLATE functions.

  • Regular Expression for Invalid Number

    Hi everyone,
    I am using oracle version as follows:
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for 32-bit Windows: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    I am using regular expression to replace invalid values from a table.
    I received oracle error stating "ORA-01722 invalid number"
    My query looks like this:
    SELECT DISTINCT
    MRC_KEY,
    PURPOSE_CD,
    RESIDENCE_DESC,
    to_number(regexp_replace(ICAP_GEN_MADAPTIVE,'[+. ]?0?0?(\d+)[-.]?','\1')) as ICAP_GEN_MADAPTIVE,
    From
    MRRC_INT
    I am not sure what are the invalid values in the table so I can write regexp accordingly.
    Any guidance is highly appreciated!
    Thanks in advance
    J

    Or use DML error logging:
    create table t1
      (col1 number);
    exec dbms_errlog.create_error_log ('t1','t1_errors')
    insert into t1
    with t as
      (select '1' col from dual union all
       select '1.1' col from dual union all
       select '.11' col from dual union all
       select '0.11' col from dual union all
       select '-1' col from dual union all
       select '1,1' col from dual union all
       select '11a' col from dual union all
       select '1d' col from dual union all
       select '1e6' col from dual union all
       select '1e6.1' col from dual union all
       select '1e' col from dual
    select col
    from t
    log errors into t1_errors
    reject limit 20
    col col1 for 999,999,999.99
    select * from t1;
               COL1
               1.00
               1.10
                .11
                .11
              -1.00
       1,000,000.00
    col col1 for a30
    select * from t1_errors;
    ORA_ERR_NUMBER$ ORA_ERR_MESG$                  ORA_ERR_ROWID$       OR ORA_ERR_TAG$         COL1
               1722 ORA-01722: invalid number                           I                       1,1
               1722 ORA-01722: invalid number                           I                       11a
               1722 ORA-01722: invalid number                           I                       1d
               1722 ORA-01722: invalid number                           I                       1e6.1
               1722 ORA-01722: invalid number                           I                       1e

Maybe you are looking for

  • If i turn off wifi my phone only goes to Edge and not 3g by default?!?!

    I have a very wierd problem with iphone. mine isn't about 3g reception, as i get eprfect reception. the problem is if i turn on wifi and am connected to a network, once i tun off wifi or get out of wifi range, my phone will automatically revent to Ed

  • Unable to open a pdf or jpeg file

    hello, i've just downloaded indesign to try it for a month.  i can't open or import my photo's with JPEG or PDF.  can someone help me?

  • HT201287 Predictive text gives odd suggestions

    i am struggling with predicti text. The recent updates seem to have messed it up and it changes the word I want.  the latest one was I correctly spelt 'fringe' and pressed return.  When I looked at the Calendar entry it said 'grange' why?  This seems

  • Installing iTunes in Vista from Backup?

    I installed Vista and what I did is backup My Music folder that I had in XP over on my other hard drive. I moved the music I had over to the music folder in Vista before I installed iTunes and when iTunes installed all the songs in the libary where d

  • Flash paper not working

    i haven't been able to get FlashPaper to work at all. No matter whether i try to use flashpaper or pdf conversion features, the process seems to hang and never finishes. Very disappointed at the moment. Any advice is welcome... petteri