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

Similar Messages

  • Introduction to regular expressions ... last part.

    Continued from Introduction to regular expressions ... continued., here's the third and final part of my introduction to regular expressions. As always, if you find mistakes or have examples that you think could be solved through regular expressions, please post them.
    Having fun with regular expressions - Part 3
    In some cases, I may have to search for different values in the same column. If the searched values are fixed, I can use the logical OR operator or the IN clause, like in this example (using my brute force data generator from part 2):
    SELECT data
      FROM TABLE(regex_utils.gen_data('abcxyz012', 4))
    WHERE data IN ('abc', 'xyz', '012');There are of course some workarounds as presented in this asktom thread but for a quick solution, there's of course an alternative approach available. Remember the "|" pipe symbol as OR operator inside regular expressions? Take a look at this:
    SELECT data
      FROM TABLE(regex_utils.gen_data('abcxyz012', 4))
    WHERE REGEXP_LIKE(data, '^(abc|xyz|012)$')
    ;I can even use strings composed of values like 'abc, xyz ,  012' by simply using another regular expression to replace "," and spaces with the "|" pipe symbol. After reading part 1 and 2 that shouldn't be too hard, right? Here's my "thinking in regular expression": Replace every "," and 0 or more leading/trailing spaces.
    Ready to try your own solution?
    Does it look like this?
    SELECT data
      FROM TABLE(regex_utils.gen_data('abcxyz012', 4))
    WHERE REGEXP_LIKE(data, '^(' || REGEXP_REPLACE('abc, xyz ,  012', ' *, *', '|') || ')$')
    ;If I wouldn't use the "^" and "$" metacharacter, this SELECT would search for any occurence inside the data column, which could be useful if I wanted to combine LIKE and IN clause. Take a look at this example where I'm looking for 'abc%', 'xyz%' or '012%' and adding a case insensitive match parameter to it:
    SELECT data
      FROM TABLE(regex_utils.gen_data('abcxyz012', 4))
    WHERE REGEXP_LIKE(data, '^(abc|xyz|012)', 'i')
    ; An equivalent non regular expression solution would have to look like this, not mentioning other options with adding an extra "," and using the INSTR function:
    SELECT data
      FROM (SELECT data, LOWER(DATA) search
              FROM TABLE(regex_utils.gen_data('abcxyz012', 4))
    WHERE search LIKE 'abc%'
        OR search LIKE 'xyz%'
        OR search LIKE '012%'
    SELECT data
      FROM (SELECT data, SUBSTR(LOWER(DATA), 1, 3) search
              FROM TABLE(regex_utils.gen_data('abcxyz012', 4))
    WHERE search IN ('abc', 'xyz', '012')
    ;  I'll leave it to your imagination how a complete non regular example with 'abc, xyz ,  012' as search condition would look like.
    As mentioned in the first part, regular expressions are not very good at formatting, except for some selected examples, such as phone numbers, which in my demonstration, have different formats. Using regular expressions, I can change them to a uniform representation:
    WITH t AS (SELECT '123-4567' phone
                 FROM dual
                UNION
               SELECT '01 345678'
                 FROM dual
                UNION
               SELECT '7 87 8787'
                 FROM dual
    SELECT t.phone, REGEXP_REPLACE(REGEXP_REPLACE(phone, '[^0-9]'), '(.{3})(.*)', '(\1)-\2')
      FROM t
    ;First, all non digit characters are beeing filtered, afterwards the remaining string is put into a "(xxx)-xxxx" format, but not cutting off any phone numbers that have more than 7 digits. Using such a conversion could also be used to check the validity of entered data, and updating the value with a uniform format afterwards.
    Thinking about it, why not use regular expressions to check other values about their formats? How about an IP4 address? I'll do this step by step, using 127.0.0.1 as the final test case.
    First I want to make sure, that each of the 4 parts of an IP address remains in the range between 0-255. Regular expressions are good at string matching but they don't allow any numeric comparisons. What valid strings do I have to take into consideration?
    Single digit values: 0-9
    Double digit values: 00-99
    Triple digit values: 000-199, 200-255 (this one will be the trickiest part)
    So far, I will have to use the "|" pipe operator to match all of the allowed combinations. I'll use my brute force generator to check if my solution works for a single value:
    SELECT data
      FROM TABLE(regex_utils.gen_data('0123456789', 3))
    WHERE REGEXP_LIKE(data, '^(25[0-5]|2[0-4][0-9]|[01]?[0-9]{1,2})$') 
    ; More than 255 records? Leading zeros are allowed, but checking on all the records, there's no value above 255. First step accomplished. The second part is to make sure, that there are 4 such values, delimited by a "." dot. So I have to check for 0-255 plus a dot 3 times and then check for another 0-255 value. Doesn't sound to complicated, does it?
    Using first my brute force generator, I'll check if I've missed any possible combination:
    SELECT data
      FROM TABLE(regex_utils.gen_data('03.', 15))
    WHERE REGEXP_LIKE(data,
                       '^((25[0-5]|2[0-4][0-9]|[01]?[0-9]{1,2})\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]{1,2})$'
    ;  Looks good to me. Let's check on some sample data:
    WITH t AS (SELECT '127.0.0.1' ip
                 FROM dual
                UNION 
               SELECT '256.128.64.32'
                 FROM dual            
    SELECT t.ip
      FROM t WHERE REGEXP_LIKE(t.ip,
                       '^((25[0-5]|2[0-4][0-9]|[01]?[0-9]{1,2})\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]{1,2})$'
    ;  No surprises here. I can take this example a bit further and try to format valid addresses to a uniform representation, as shown in the phone number example. My goal is to display every ip address in the "xxx.xxx.xxx.xxx" format, using leading zeros for 2 and 1 digit values.
    Regular expressions don't have any format models like for example the TO_CHAR function, so how could this be achieved? Thinking in regular expressions, I first have to find a way to make sure, that each single number is at least three digits wide. Using my example, this could look like this:
    WITH t AS (SELECT '127.0.0.1' ip
                 FROM dual
    SELECT t.ip, REGEXP_REPLACE(t.ip, '([0-9]+)(\.?)', '00\1\2')
      FROM t
    ;  Look at this: leading zeros. However, that first value "00127" doesn't look to good, does it? If you thought about using a second regular expression function to remove any excess zeros, you're absolutely right. Just take the past examples and think in regular expressions. Did you come up with something like this?
    WITH t AS (SELECT '127.0.0.1' ip
                 FROM dual
    SELECT t.ip, REGEXP_REPLACE(REGEXP_REPLACE(t.ip, '([0-9]+)(\.?)', '00\1\2'),
                                '[0-9]*([0-9]{3})(\.?)', '\1\2'
      FROM t
    ;  Think about the possibilities: Now you can sort a table with unformatted IP addresses, if that is a requirement in your application or you find other values where you can use that "trick".
    Since I'm on checking INET (internet) type of values, let's do some more, for example an e-mail address. I'll keep it simple and will only check on the
    "[email protected]", "[email protected]" and "[email protected]" format, where x represents an alphanumeric character. If you want, you can look up the corresponding RFC definition and try to build your own regular expression for that one.
    Now back to this one: At least one alphanumeric character followed by an "@" at sign which is followed by at least one alphanumeric character followed by a "." dot and exactly 3 more alphanumeric characters or 2 more characters followed by a "." dot and another 2 characters. This should be an easy one, right? Use some sample e-mail addresses and my brute force generator, you should be able to verify your solution.
    Here's mine:
    SELECT data
      FROM TABLE(regex_utils.gen_data('a1@.', 9))
    WHERE REGEXP_LIKE(data, '^[[:alnum:]]+@[[:alnum:]]+(\.[[:alnum:]]{3,4}|(\.[[:alnum:]]{2}){2})$', 'i'); Checking on valid domains, in my opinion, should be done in a second function, to keep the checks by itself simple, but that's probably a discussion about readability and taste.
    How about checking a valid URL? I can reuse some parts of the e-mail example and only have to decide what type of URLs I want, for example "http://", "https://" and "ftp://", any subdomain and a "/" after the domain. Using the case insensitive match parameter, this shouldn't take too long, and I can use this thread's URL as a test value. But take a minute to figure that one out for yourself.
    Does it look like this?
    WITH t AS (SELECT 'Introduction to regular expressions ... last part. URL
                 FROM dual
                UNION
               SELECT 'http://x/'
                 FROM dual
    SELECT t.URL
      FROM t
    WHERE REGEXP_LIKE(t.URL, '^(https*|ftp)://(.+\.)*[[:alnum:]]+(\.[[:alnum:]]{3,4}|(\.[[:alnum:]]{2}){2})/', 'i')
    Update: Improvements in 10g2
    All of you, who are using 10g2 or XE (which includes some of 10g2 features) may want to take a look at several improvements in this version. First of all, there are new, perl influenced meta characters.
    Rewriting my example from the first lesson, the WHERE clause would look like this:
    WHERE NOT REGEXP_LIKE(t.col1, '^\d+$')Or my example with searching decimal numbers:
    '^(\.\d+|\d+(\.\d*)?)$'Saves some space, doesn't it? However, this will only work in 10g2 and future releases.
    Some of those meta characters even include non matching lists, for example "\S" is equivalent to "[^ ]", so my example in the second part could be changed to:
    SELECT NVL(LENGTH(REGEXP_REPLACE('Having fun with regular expressions', '\S')), 0)
      FROM dual
      ;Other meta characters support search patterns in strings with newline characters. Just take a look at the link I've included.
    Another interesting meta character is "?" non-greedy. In 10g2, "?" not only means 0 or 1 occurrence, it means also the first occurrence. Let me illustrate with a simple example:
    SELECT REGEXP_SUBSTR('Having fun with regular expressions', '^.* +')
      FROM dual
      ;This is old style, "greedy" search pattern, returning everything until the last space.
    SELECT REGEXP_SUBSTR('Having fun with regular expressions', '^.* +?')
      FROM dual
      ;In 10g2, you'd get only "Having " because of the non-greedy search operation. Simulating that behavior in 10g1, I'd have to change the pattern to this:
    SELECT REGEXP_SUBSTR('Having fun with regular expressions', '^[^ ]+ +')
      FROM dual
      ;Another new option is the "x" match parameter. It's purpose is to ignore whitespaces in the searched string. This would prove useful in ignoring trailing/leading spaces for example. Checking on unsigned integers with leading/trailing spaces would look like this:
    SELECT REGEXP_SUBSTR(' 123 ', '^[0-9]+$', 1, 1, 'x')
      FROM dual
      ;However, I've to be careful. "x" would also allow " 1 2 3 " to qualify as valid string.
    I hope you enjoyed reading this introduction and hope you'll have some fun with using regular expressions.
    C.
    Fixed some typos ...
    Message was edited by:
    cd
    Included 10g2 features
    Message was edited by:
    cd

    Can I write this condition with only one reg expr in Oracle (regexp_substr in my example)?I meant to use only regexp_substr in select clause and without regexp_like in where clause.
    but for better understanding what I'd like to get
    next example:
    a have strings of two blocks separated by space.
    in the first block 5 symbols of [01] in the second block 3 symbols of [01].
    In the first block it is optional to meet one (!), in the second block it is optional to meet one (>).
    The idea is to find such strings with only one reg expr using regexp_substr in the select clause, so if the string does not satisfy requirments should be passed out null in the result set.
    with t as (select '10(!)010 10(>)1' num from dual union all
    select '1112(!)0 111' from dual union all --incorrect because of '2'
    select '(!)10010 011' from dual union all
    select '10010(!) 101' from dual union all
    select '10010 100(>)' from dual union all
    select '13001 110' from dual union all -- incorrect because of '3'
    select '100!01 100' from dual union all --incorrect because of ! without (!)
    select '100(!)1(!)1 101' from dual union all -- incorrect because of two occurencies of (!)
    select '1001(!)10 101' from dual union all --incorrect because of length of block1=6
    select '1001(!)10 1011' from dual union all) --incorrect because of length of block2=4
    select '10110 1(>)11(>)0' from dual union all)--incorrect because of two occurencies of (>)
    select '1001(>)1 11(!)0' from dual)--incorrect because (!) and (>) are met not in their blocks
    --end of test data

  • Search for a regular expression in a 1D array?

    I've got a 1D array of strings, and I want to find the row with "Date: yy/mm/dd" in it. Since yy/mm/dd would not necessarily be the same between runs, I can't look for the row with "Date: yy/mm/dd".
    I tried using the Search 1D Array with "Date: " and "Date: *" as my element input, but it didn't find either of 'em.
    I don't know where in vi.lib the function would be in, otherwise I'd attempt to mod the function to take regular expressions, and my off-the-cuff search attempt (looping through the array & using Match Regular Expression) had some odd errors and still didn't find the row.
    Thanks!

    What do you define as a "row"? Is each row a single array element? Since your array elements are strings, each array element itself could be a multiline|multirow string itself that might need to be analyzed one row at a time.
    To look for patterns:
    If you have LabVIEW 8.0 or higher, you can use "Match regular expression". Else you can use "Match Pattern". It really depends how specific you need to be. Are there lines that start with "Date:" but don't contain a formatted date afterwards?
    To search for array elements starting with simple string "Date:", use "match first string".
    LabVIEW Champion . Do more with less code and in less time .

  • Difference between regular expressions and spry character masking?

    Hi,
    This is my first time writing my own regular expressions.  Often times though, they seem to work in various testing widgets, but then they do not perform as expected in Spry.  I have no idea how to even begin to debug this.
    For example, this string:
    ^\#?[A-Fa-f0-9]{3}([A-Fa-f0-9]{3})?$
    Does a perfect job enforcing hex colors in a regexp testing widget.  But it doesn't work in spry.  It won't let me type a darn thing in.
    Can somebody throw me a bone here?

    Hi!
    Thank you for the response.  I read that article prior to posting and it seems to relate more to Spry's custom pattern function rather than regular expressions.  Here's the code I have:
    <script type="text/javascript">
         <!--     
              var text_1 =
              new Spry.Widget.ValidationTextField(
                   "text_1",
                   "none",
                   {regExpFilter:/^#[A-Fa-f0-9]{6,};$/,
                   useCharacterMasking:true,
                   validateOn:["change"]})
         //-->
    </script>
    Expected behavior:  I should be able to type in a valid hex color and have Spry perform validation.
    Actual behavior:  I can't type anything in, at all.  I immediately get the invalid Spry feedback (in my case a little red .png image and an error message).
    Simpler expressions like this work fine in Spry:
                        <script type="text/javascript">
         <!--
              var text_1 =
                   new Spry.Widget.ValidationTextField(
                   "text_1",
                   "none",
                   {regExpFilter:/[a-z]/,
                   useCharacterMasking:true,
                   validateOn:["change"]})
         //-->
    </script>
    I think if I can figure out what the special rules are for one somewhat robust regular expression in Spry, then I will be off and running.
    Can anyone help?
    Scott

  • Regular Expression Search in Forms Builder

    Hi everyone, can anyone help me out?
    I'm working on a legacy forms migration project (3 to 10g) where item references often do not include the block name.
    eg.
    :stock_level := :default_level;
    instead of
    :stk.stock_level := :ctrl.default_level;
    There are also instances of set_item_property('stock_level',....)
    In complex multi-block forms this obviously makes the form difficult to understand.
    Is there a way in which I can search the triggers and program units of a form for items that don't have a block prefix? The Forms search and replace function has a Regular Expression feature, but I have no experience in this area.
    I assume I'm looking for something like this:- ":", followed by a character string that doesn't contain a "." or "="
    Thanks

    You might have a look at the commercial product formsAPIMaster, it has the ability to do such searches (and also automatic replacements, if needed)

  • VISA Find resource function regular expression

    Hi guys,
    I've been trying to get which Serial port is a GPS receiver connected to using the VISA Find Resource Function with no luck. The idea is to use a regular expression similar to
    ASRL?*INSTR{VI_ATTR_ASRL_BAUD == 9600}
    but instead of looking for baud rate, I want to search the value
    ASRL3 (COM3 - GNSS Receiver)
    as seen in MAX/VISA Test Panel. The attribute name is VI_ATTR_INTF_INST_NAME.
    Something like ASRL?*INSTR{VI_ATTR_INTF_INST_NAME == ASRL? (COM? - GNSS Receiver)} should work, but it's not.
    How should I write the expression?
    Thanks!
    Best regards,
    Néstor
    LabVIEW 2011 + Windows 7 32bits SP1

    Hi Dennis,
    thanks for answering.
    I haven't assigned the name, MAX did it. I just opened MAX and there it was, COM3 (In Devices and interfaces/ASRL3/settings/name). I suppose it gets directly the Windows serial port name, what name do you mean exactly?
    Anyway, what I'm interested in getting is the Port description, that would tell me the connected device in that port. I could build a small loop and look for the interface description of each serial device, but I found the VISA Find Resourde function and it seems a more simple and direct way to get what I want.
    If I can list all serial devices with 9600 baud rate as in the previous example, why not do the same with the instrument name? I clearly see it when I open the VISA Test Panel. I am maybe missing something?
    Best regards,
    Néstor
    LabVIEW 2011 + Windows 7 32bits SP1

  • Unable To Use Regular Expression To Find Function Names

    Hi,
    I am trying to create a regular expression to find function and procedure names without the static designation and the parameter list.  Sample source document:
    static function test
    static function test(i,j)
    function test
    function test(i,j)
    static procedure test
    static procedure test(i,j)
    procedure test
    procedure test(i,j)
    For each of the above samples, I would like only the word "test" to be found.
    Thanks

    I suggest starting with this expression:
    ^\s*(static\s+)?(function|procedure)\s+(?<NAME>\w+)
    Programmatically, the name can be extracted from the group called “NAME”.
    The expression can be improved.

  • Regular Expression functions not supported in Interactive report filters ??

    I'm using APEX 4.0.2 and I'm trying to create a row filter in an interactive report which uses regexp_instr and regexp_replace functions and I'm getting the message:
    Invalid filter expression. regexp_instr
    The code runs fine in SQL Workshop
    select cytogenetics from z_patient
    where regexp_instr(regexp_replace(cytogenetics,'(\,+|\"+|\s)',''),'(^46XX$|^46XY$|^46XX\[..\]$|^46XY\[..\]$)')=1
    CYTOGENETICS
    "46,XX [20]"
    "46,XY[20]"
    "46,XX"
    "46,XY[20]"
    "46,XY[30]"
    "46,XY[26]"
    "46,XY [33]"
    "46,XX[32]
    etc...
    my filter is just the where clause above i.e.
    regexp_instr(regexp_replace(cytogenetics,'(\,+|\"+|\s)',''),'(^46XX$|^46XY$|^46XX\[..\]$|^46XY\[..\]$)')=1
    *Are regular expression functions just not supported in interactive report filters?*
    thanks in advance
    Paul P

    Hi Paul,
    regular expression functions are supported in interactive report filters, but it looks like that REGEXP_INSTR hasn't been added as valid command. Only REGEXP_SUBSTR and REGEXP_REPLACE are valid commands for computation expressions and REGEXP_SUBSTR, REGEXP_REPLACE and REGEXP_LIKE for row level filters.
    I have filed bug# 12926266 to fix this issue. Sorry for the inconvenience.
    Regards
    Patrick
    My Blog: http://www.inside-oracle-apex.com
    APEX 4.0 Plug-Ins: http://apex.oracle.com/plugins
    Twitter: http://www.twitter.com/patrickwolf

  • Regular Expression for Match Pattern (string) Function

    I need to find a variable length string enclosed by brackets and
    within a string. Can't seem to get the regular expression right for
    the Match Pattern function. I'm able to get the job done using the
    Token function, but it's not as slick or tight as I'd like. Does
    anybody out there have the expression for this?

    Jean-Pierre Drolet wrote in message news:<[email protected]>...
    > The regular expression is "\[[~\]]*\]" which means:
    > look for a bracket "\[" (\ is the escape char)
    > followed by a string not containing a closing bracket "[~\]]*"
    > followed by a closing bracket "\]". The match string include the
    > brackets
    >
    > You can also read "Scan from String" with the following format:
    > "%[^\[]\[%[^\[\]]" and read the 2nd output. The brackets are removed
    > from the scanned string.
    Thanks, Jean_Pierre
    I did some more experimenting after posting and found that \[.*\] also
    works with the match pattern function. Thanks for your input.
    sm

  • Passing regular expression backreference to SQL function

    Does anyone know if it is possible to pass a regular expression backreference to an SQL function?
    When I try this:
    SELECT REGEXP_REPLACE('/abc/23468/xyz1/10/', '(/)([[:digit:]]+)', '\1'||LENGTH('\2')) FROM dual;
    I am getting this back:
    /abc/2/xyz1/2/
    Here LENGTH function takes backreference '\2' literally as a string and does not replace it with the actual value.
    Hence, it always returns length of 2 instead of the correct value.
    However, if do this
    SELECT REGEXP_REPLACE('/abc/23468/xyz1/10/', '(/)([[:digit:]]+)', '\1'||SUBSTR('\2',0)) FROM dual;
    I get the right result back
    /abc/23468/xyz1/10/
    So, SUBSTR works correctly.
    Why do LENGTH and SUBSTR handle backreference diffrently?
    I am using Oracle 10.2.
    Appreciate any help on this.

    How about this?
    CREATE OR REPLACE FUNCTION fmt_string(
      p_Source IN VARCHAR2,
      P_Delim  IN VARCHAR2 DEFAULT '/'
    ) RETURN VARCHAR2
    IS
      v_Start  PLS_INTEGER;
      v_Pos    PLS_INTEGER;
      v_Len    PLS_INTEGER;
      v_String VARCHAR2(4000);
      v_Result VARCHAR2(4000);
    BEGIN
      v_Len   := LENGTH(p_Source);
      v_Start := 1;
      WHILE v_Start <= LENGTH(p_Source)
      LOOP
        v_Pos := INSTR(p_Source, p_Delim, v_Start);
        IF v_Pos = 0 THEN
           v_Pos := v_Len;
        END IF;
        v_String := SUBSTR(p_Source, v_Start, v_Pos - v_Start);
        IF REGEXP_LIKE(v_String, '^[0-9]+$') THEN
           v_String := TO_CHAR(TO_NUMBER(v_String), 'fm0000000000');
        END IF;
        v_Result := v_Result || v_string || p_Delim;
        v_Start  := v_Pos + 1;
      END LOOP;
      RETURN v_Result;
    END fmt_string;
    /using it this way:
    SELECT fmt_string('/abc/23468/xyz1/10/')
      FROM dual;You could put that function also into a PACKAGE.
    C.

  • Match Regular Expression Function input string format

    Hi,
    I am new to labview and was having some difficulties using the Match Regular Experssion Function.  
    I am using labview to communicate with a sensor.  I have installed the NI device driver to do so.  The output of my sensor is in the format, 
    X20
    R40 P20 A123.  The numbers in this case are arbitrary.  I am trying to use Match Regular Expression Function to display and perform mathematical operations on the numbers.  I am having difficulties formatting the input string on the Match Regular Expression Function.  Could you please give me some tips on how to format the example I provided.  
    Thank

    MoAgha wrote:
    Hi,
    I am new to labview and was having some difficulties using the Match Regular Experssion Function.  
    I am using labview to communicate with a sensor.  I have installed the NI device driver to do so.  The output of my sensor is in the format, 
    X20
    R40 P20 A123.  The numbers in this case are arbitrary.  I am trying to use Match Regular Expression Function to display and perform mathematical operations on the numbers.  I am having difficulties formatting the input string on the Match Regular Expression Function.  Could you please give me some tips on how to format the example I provided.  
    Thank
    Here is a way to do it if the format is constant (X R P A followed by a positive integer number).
    Ben64

  • OWA_PATTERN regular expressions CHANGE function

    Hello,
    I'm trying to use the CHANGE function to match an expression and then change the matched part of the string. The twist is that I would like to pass the matched part of the string through a function before it is replaced in the original string. Here is an example:
    Pattern: 'C'
    Text: 'CAAACAAAC'
    Resulting text: 'DAAADAAAD'
    Where the 'D' is the result of calling a function. The actual call to the OWA_PATTERN.CHANGE looks something like this:
    OWA_PATTERN.CHANGE(mytext,'C',myfunction(&))
    where the & argument to myfunction is as specified in the ORACLE docs as a reference to what was matched. The line of code doesn't work however. Anyone ever done anything like this?
    Aziz 8)

    SQL> CREATE OR REPLACE FUNCTION myfunction
      2    (p_pattern IN VARCHAR2)
      3    RETURN      VARCHAR2
      4  AS
      5  BEGIN
      6    RETURN CHR (ASCII (p_pattern) + 1);
      7  END myfunction;
      8  /
    Function created.
    SQL> CREATE OR REPLACE PROCEDURE test_pattern
      2    (pattern IN VARCHAR2,
      3     text    IN VARCHAR2)
      4  AS
      5    mytext      VARCHAR2 (256);
      6  BEGIN
      7    mytext := text;
      8    owa_pattern.change (mytext, pattern, myfunction (pattern), 'g');
      9    DBMS_OUTPUT.PUT_LINE ('Pattern:         ' || pattern);
    10    DBMS_OUTPUT.PUT_LINE ('Text:            ' || text);
    11    DBMS_OUTPUT.PUT_LINE ('Resulting text:  ' || mytext);
    12  END test_pattern;
    13  /
    Procedure created.
    SQL> SET SERVEROUTPUT ON
    SQL> EXECUTE test_pattern ('C', 'CAAACAAAC')
    Pattern:         C
    Text:            CAAACAAAC
    Resulting text:  DAAADAAAD
    PL/SQL procedure successfully completed.

  • Regular Expression / replace Function Help

    The problem:
    cfset myString = "i am a big boy"
    cfset outputString = replace("i am a big
    boy","i","you","all")
    Wrong Output:
    you am a byoug boy
    Intended Output
    you am a big boy
    How do I achive that output.

    Your first example had only one sentence. That's why I gave
    that answer.
    Anyway for your real question, you need to use regular
    expressions
    #rereplace(myString,"i\s","you ","all")# - will give u
    you am a big boy you am a big boy you am a big boy you am a
    big boy.
    \s looks for a whitespace character after the letter i. So
    that way it will not change the letter i in big

  • Match Regular Expression Function

    Hi guys, using this pattern I got this error:
    -4600 Error occurred during regular expression match.
    I have attached the VI.
    can you help me?thank you
    Solved!
    Go to Solution.
    Attachments:
    Untitled 2.vi ‏30 KB

    inuyasha84 wrote:
    hi well i want to save (create) a file and do a check to see if the new file that I want to create already exist or not. so the idea was to see if the path of the new file is equal to the old path
    Why not just use "Check if file or folder exists"? (File I/O -> Adv File Funcs)
    Cameron
    To err is human, but to really foul it up requires a computer.
    The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
    Profanity is the one language all programmers know best.
    An expert is someone who has made all the possible mistakes.
    To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):
    LabVIEW Unit 1 - Getting Started
    Learn to Use LabVIEW with MyDAQ

  • ? on Regular Expressions

    I am trying to use a regular expression to spot an empty string but it isn't working within Oracle ... regexp_like(:P13_ADDRESS,'^$')
    Shouldn't this expression work '^$' ???????

    Justin,
    a few Oracle facts regarding the handling of null values:
    1) the empty string '' is equivalent to NULL
    2) an operation (using oracle built-in operators / functions) on a NULL value will always result in a null value
    consider the following example for illustration purposes:
    set serveroutput on
    DECLARE
       l_str   VARCHAR2 (100);
    BEGIN
       l_str := '';
       IF l_str IS NULL THEN
          DBMS_OUTPUT.put_line ('empty string is null');
       END IF;
       IF TO_NUMBER ('') IS NULL THEN
          DBMS_OUTPUT.put_line ('conversions on null will yield null as output');
       END IF;
    END;
    That's what it seems to be doing, as my example showed. I don't quite agree with this,
    NULL is a RDBMS concept, it should match a empty string (^$), but Oracle's regexp
    implementation doesn't seem to be doing this, so just NVL it.Well, regarding the logic behind (2), that all operations on a null value will result in a null value, it does indeed make sense that the regular expression applied to null returns null.
    And in a boolean context (like in the if-clause) null will be equivalent to false. This can be tricky at times!
    Thus I would use the following code (illustrated by a stored function) to check for an empty string
    CREATE OR REPLACE FUNCTION is_empty (p_str IN VARCHAR2)
       RETURN BOOLEAN IS
       l_str   VARCHAR2 (2000) := TRIM (p_str);  -- remove leading and trailing spaces
    BEGIN
       IF l_str IS NULL THEN
          RETURN TRUE;
       ELSE
          RETURN FALSE;
       END IF;
    END;
    /~Dietmar.

Maybe you are looking for

  • Getting error while installing UCM in Linux

    Hi All, I'm trying to install UCM in Linux system. I installed OHS(Oracle Http Server) and also installed RCU. While installing the UCM it taking all the inputs and while installing folder structure after that it's trying to start the server. that ti

  • PCI Modem in a B&W G3?

    Hello, I am interested in putting a modem into a B&W G3. I have found some good prices for PCI modems on ebay, however, I am not sure if these modems will work in my computer. I know that one of the great things about Macs is that installation of dri

  • ADF Shuttle Select Items rendered as checkboxes

    So, we are using ADF 11.1.2.4 to develop our application.  We have a requirement to use the shuttle control.  However, when it is rendered, it contains checkboxes (inputItem type=checkbox).  I am pretty sure this wasn't happening with 11.1.2.3, but w

  • Make printed digital signature disappear if document altered

    We have created a document and digitally signed it.  We have then altered the document.  When the document is viewed on the screen the signature shows as invalid. When the document is printed, however, the signature is the same. Is there a way of eit

  • How to unzip  a .tar.tar file

    Hi , I have downloaded jexel api from net. But it come as jexcelapi_2_5_9.tar.tar. i tried to unzip using winzip. But its not working. Can anybody tell how to unzip this?