Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: OWA_PATTERN to remove any html
> Hi all,
>
> I'm trying to express a regular expression to remove any html in a given
> varchar2 variable. I've found the regular expression to do this in perl.
> It's:
>
> $OnlyContent =~ s{<([^>])+>|&([^;])+;}{}gsx;
>
> When I try to use this regular expression in PL/SQL I get the command:
>
> L_source := '<html><body><b>test</b><a
> href="http://www.test.com">something</a></body></html>';
> L_count := OWA_PATTERN.CHANGE(L_source, '<([^>])+>|&([^;])+;', '', 'gi');
>
> Every time I try to execute this, I get the following errors:
> ORA-06502: PL/SQL: numeric or value error: character to number conversion
> error
> ORA-06512: at "SYS.OWA_PATTERN", line 444
> ORA-06512: at "SYS.OWA_PATTERN", line 579
> ORA-06512: at "SYS.OWA_PATTERN", line 1120
>
> Could anybody tell me, what's wrong with the regular expression or how I
> could express a regular expression which removes any html in a given
> varchar2???
>
Ingo
I have the hunch that | is not supported in OWA_PATTERN's RE. Also, I have the feeling that the paranthesis can be omitted.
The following seems to work here:
declare
L_source varchar2(200);
L_count number;
begin
L_source :=
'<html><body><b>test</b>something</body></html>';
L_count := OWA_PATTERN.CHANGE(L_source, '<[^>]+>','','gi'); L_count := OWA_PATTERN.CHANGE(L_source, '\&[^;]+;', '', 'gi');
dbms_output.put_line(L_source);
end;
/
hth
Rene Nyffenegger
-- Projektleitung und Entwicklung in Oracle/C++/C# Projekten http://www.adp-gmbh.ch/cv.htmlReceived on Wed Apr 23 2003 - 12:57:31 CDT