Hello,
I'm using an Oracle 11.g procedure. I found an example of REGEXP_REPLACE with only two arguments (input and pattern) and created a procedure based on that example. The Replace function works, but not optimally. I'm trying to use REGEXP_REPLACE in order to loop through a variable number of occurrences of a particular text string within a CLOB local variable. The string occurs after the text base64, (base64 comma) and before the text " /> (double-quote space forward-slash greater-than). I can make the replace work for a single occurrence, but I can't make it loop properly. These embedded strings comprise images that have been inserted into an Apex rich-text field. That rich-text field is assigned to the CLOB p_html.
Declare p_html clob;
l_image_clob clob;
l_image_count number;
Begin
p_html := '<p>Some header text base64,one start here and then this is the end one" /></p><p>Some header text base64,two start here and then this is the end two" /></p>';
l_image_count := REGEXP_COUNT(p_html, 'base64', 1, 'i');
If l_image_count > 0 Then
For i In 1..l_image_count Loop
l_image_clob := REGEXP_REPLACE(p_html, '(.*base64,)|(" />.*)');
dbms_output.put_line(l_image_clob);
-- code to process each occurrence individually.
End Loop;
End If;
End;
What I'd like to see for data results are:
one start here and this is the end one
two start here and this is the end two
The results I'm getting are:
two start here and this is the end two
two start here and this is the end two
Thanks very much for looking at this.