Here are a number of examples using the OWA_PATTERN package:


declare
        tstr varchar2(100) := 'this contains tabs               multiple spaces      and single spaces';
begin
        dbms_output.put_line( tstr);
        owa_pattern.change( tstr, '\s', '', 'g');
        dbms_output.put_line( tstr);
end;
/
declare
        tstr varchar2(100) := 'this c34ontains s0239everal 2340 numeric 882 dig2its';
begin
        dbms_output.put_line( tstr);
        -- remove the digits
        owa_pattern.change( tstr, '\d', '', 'g');
        dbms_output.put_line( tstr);
        -- remove the extra spaces
        owa_pattern.change( tstr, '\s+', ' ', 'g');
        dbms_output.put_line( tstr);
end;
/

drop table owatest;

create table owatest (
        test varchar2(20)
)
/

insert into owatest values('non numeric row');
insert into owatest values('numeric 23423 row');

commit;

select *
from owatest
where owa_pattern.amatch(test,1,'^.*\d') > 0
/



drop table regex;

create table regex (
        test varchar2(20)
);


create or replace function strip_str (
        data_in varchar2
        --, regex_in varchar2
)
return varchar2
is
        test_str varchar2(4000);
begin
        test_str := data_in;
        --owa_pattern.change(test_str, regex_in, '', 'g');
        owa_pattern.change(test_str, '\x0a', '', 'g');
        owa_pattern.change(test_str, '\x0c', '', 'g');
        owa_pattern.change(test_str, '\x0d', '', 'g');
        return test_str;

end;
/

show error function strip_str

insert into regex values( 'carriage' || chr(13) || 'return');
insert into regex values( 'line' || chr(10) || 'feeds' || chr(10));
insert into regex values( 'form feed' || chr(12));

commit;

select test
from regex;

select strip_str(test) test
from regex
/



"Shiva Maran" <[EMAIL PROTECTED]>
Sent by: [EMAIL PROTECTED]

 11/06/2003 11:19 PM
 Please respond to ORACLE-L

       
        To:        Multiple recipients of list ORACLE-L <[EMAIL PROTECTED]>
        cc:        
        Subject:        pattern search



Hi All,

 I need a means to search for a pattern (With basic wildcard characters like %, _, ^, []). How do I do this in oracle. I also need to get back the string that matches the pattern. Is there any predefined function or procedure that does this. Would like to avoid implementing this on my own.

TIA,
ShivaM

DISCLAIMER: This e-mail contains proprietary information some or all of which may be legally privileged.
It is for the intended recipient only. If an addressing or transmission error has misdirected this e-mail,
please notify the author by replying to this e-mail. If you are not the intended recipient, you must not use,
save, disclose, distribute, copy, print or relay this e-mail.

--
Please see the official ORACLE-L FAQ: http://www.orafaq.net
--
Author: Shiva Maran
 INET: [EMAIL PROTECTED]

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).


Reply via email to