REGEXP_REPLACE how to loop through the occurrences of a text string variables

Hello

I use a 11.g Oracle procedure. I found an example of REGEXP_REPLACE with only two arguments (input and model) and created a procedure based on this example. The Replace function works, but not optimally. I try to use REGEXP_REPLACE to loop on a variable number of occurrences of a text string in a local variable of CLOB.  The string occurs after the text base64 (base64 comma) and before the text "/ > (double quote space oblique superior - only)."  I can do replace it work for a single occurrence, but I can't do it properly in a loop.  These embedded strings include images that were inserted in a rich Apex text field.  This is a 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 would like to see results of the data are:

tenure here and that's the end

two beginning here and that's the end of two

The results I get are:

two beginning here and that's the end of two

two beginning here and that's the end of two

Thanks a lot for watching this.

Hello

From Oracle 11.1, REGEXP_SUBSTR is better than REGEXP_REPLACE for this sort of thing.

What produces the output you asked for:

Declare

CLOB p_html;

CLOB l_image_clob;

number of l_image_count;

Begin

p_html: = '

' Some header text base64, start here and then it's the end "/ >

Some header text base64, two start here and then it's the end of two"/ >

';

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_SUBSTR (p_html )

, "base64,(.*?)" / > "

1

, I - letter i (loop variable), not number 1

, 'i'

1

);

dbms_output.put_line (l_image_clob);

-code to treat each case individually.

End loop;

End If;

End;

/

The 4th argument to REGEXP_SUBSTR specifies where desired appearance (starting with 1).

The 6th argument is a backreference. 1 means you want to return all that match the expression starting with the 1st '('. gauche)

Tags: Database

Similar Questions

  • How to loop through the CSV file

    Hello

    I want to loop through each column in a CSV file.
    And while the closure of each column, I want to loop every line starting with line 2 St.

    I wrote the code below, but it's a loop in the lines from rank 1.
    How can I start the loop from the 2nd row in the CSV file?
    (see code below)

    Can someone tell me how to proceed?

    THX




    <!-Download and read the file CSV - TXT->
    < cffile action = "read" variable = "C:\Documents and Settings\user\Desktop\EM-CSV\test.csv" file = "csvfile" >

    <!-browse the CSV - TXT file on line breaks and insert into the database->
    < table border = "1" >


    < cfloop index = list 'index' = "' #csvfile # ' delimiters =" #chr (10) ##chr (13) #">"

    <!-< cfoutput > #listgetAt('#index#',1, ',') # < / cfoutput > < br >->
    < b >
    < td > < cfoutput #index # > < / cfoutput > < table >
    < td > < cfoutput > #listgetAt('#index#',2, ',') # < / cfoutput > < table >
    < td > < cfoutput > #listgetAt('#index#',3, ',') # < / cfoutput > < table >
    < /tr >

    < / cfloop >
    < /table >

    Hi Like2Flex,

    The problem is that coldfusion does not see

    list = "a, b, c, d.

    as a list of 9 things you expect. He just sees 4 elements a, b, c and d because Coldfusion does not include two delimiters next to each other.

    A solution to the problem is to manually insert a space between two delimiters that are side by side. Here is an example of such a solution




    length of the list: #listlen (list) #

  • How to loop through the results of a select statement in a process flow?

    Hello

    I use Warehouse Builder 10 g R2.

    I'm trying to implement a loop in a process stream that runs through the results of a select statement.

    In pl/sql, it would be implemented as a for loop by using a slider, but I simply doesn't work how to do this using the loops in the process flow.

    Someone at - it ideas?

    Thank you
    Liffey

    Liffey,
    Look at this thread
    For or while loop a loop in the process flow

    Kind regards
    Oleg

  • Loop through the list, search for text

    If I'm a loop in a list and try to find the text that I am looking to make a selection, how could it achieve that?

    < cfif = text "TheTextI'mLookingFor > < / cfif >?"

    you would use the function find of FindNoCase.

    http://help.Adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7E 7c.html

  • How to loop through the values of token

    I am trying to create a simple loop that runs through a bunch of values delimited by commas in a string and add them up. What is the best way to do it?

    Currently, my code looks like this

    < cfset basevalue = "0" >
    < cfset count = "1" >
    < cfset token = getToken (myString, count, ",") >
    < cfloop condition = "token QNE NULL" >
    < cfset token = getToken (myString, count, ",") >
    < cfset basevalue = basevalue + token >
    < cfset count = count + 1 >
    < / cfloop >

    This doesn't seem to work. Any ideas?

    I think that the correct syntax is index = "token". If you have some other delimiter then,




    Thank you

  • How to loop through the layers of the children of a group with jsx?

    Need to change the name of a child layers in a group? How to get there?

    Kind regards

    Dorothy

    What is giving you problems?

    Perhaps this example can help:

    #target photoshop
    var theLayers = collectLayers(app.activeDocument.activeLayer, []);
    alert (theLayers.join("\n"));
    ////// function collect all layers //////
    function collectLayers (theParent, allLayers) {
      if (!allLayers) {var allLayers = new Array}
      else {};
      var theNumber = theParent.layers.length - 1;
      for (var m = theNumber; m >= 0;m--) {
      var theLayer = theParent.layers[m];
      theLayer.name = theParent.name + "_" + m;
    // apply the function to layersets;
      if (theLayer.typename == "ArtLayer") {
      allLayers.push(theLayer)
      }
      else {
      allLayers = (collectLayers(theLayer, allLayers))
    // this line includes the layer groups;
      allLayers.push(theLayer);
      }
      };
      return allLayers
      };
    
  • How to scroll through the entire screen of text

    I'm new to Captivate.  In other words, I use it for the first time.  I am trying to create the first slide in my project.  I want a text to scroll on the right screen and completely out of the screen on the left.  I was able to make the text fade in and out and have music in the background (at first), but I can't understand how the full scroll from right to left, or if it is possible.


    Can someone help me with this and please give step by step instructions?  I would be very happy!

    Hello and welcome to the forums.  You don't say what version of Captivate you use, but if you have version 5 or 5.5, the answer is Yes, you can have a blade of legend of text on the screen.  You can use a to do.  To open the effect controls panel, use the window menu, and then select effects.  Select the caption text that you want to have the scroll.  I'll demonstrate using version 5.  You should see:

    Click on the fx to open the menu effects.  Select the trajectory, then RightToLeft.

    Drag the right end of the effect of RightToLeft to length of parchment.  Here I show that I have extended it to the length of the slide, 3 seconds:

    Then look at the text of the caption on the slide.  If it is enabled, you should see a 1 in his lower right:

    The 1-click and you will get starting and ending points of the motioin effect.  Drag the start point at the right edge of the blade and the end point at the left edge of the slide.

    When the slide plays, the text caption will start on the right edge of the screen and pass through and leave the left edge of the screen in 3 seconds.

    I hope this helps.

    Mister C.

  • loop through the layers defining the lock and visibility

    I need to loop through the layers in the active document and the value of the properties of the layer is false or true.  I tried to create a loop using a method 'for', but it doesn't seem to work. I have renounced the method 'for' because I kept running into a problem.  I have set all layers with these settings just the odd ones (2,4,6, etc.). Here is sample if it was written.

    myLayer = myDoc.layers var [2];

    myLayer.visible = false;

    myLayer.locked = true;

    myLayer = myDoc.layers var [4];

    myLayer.visible = false;

    myLayer.locked = true;

    myLayer = myDoc.layers var [6];

    myLayer.visible = false;

    myLayer.locked = true;

    myLayer = myDoc.layers var [8];

    myLayer.visible = false;

    myLayer.locked = true;

    I have 208 layers, so doing it this way would be way to long. Any help would be appreciated.

    Illustrator CC 2014 running.

    After I wrote this and tested, I saw that Carlos had already answered, but I thought that I would post it anyway. Carlos KNOWS how much I love JS... ;-)

    One difference is that, since it was not clear to me which layer you talk like layer #1, I started at the bottom of the scale.  I hope this helps.  -TT

    var aDoc = app.activeDocument;
    var lc = aDoc.layers.length;
    for (var i = 2; i <= lc; i+=2) {
        var curLayer = lc - i
        aDoc.layers[curLayer].visible = false;
        aDoc.layers[curLayer].locked = true;
    }
    
  • Scripting inDesign: Loop through the layers

    I'm doing a script that will:

    To loop through all the layers in a document.

    Add the layers unlocked in table

    Loop in this table and glue them in place on each layer.

    I don't know how to loop through all the layers.

    Here is my script (I used? to represent where would the loop through all the part of layers):

    JavaScript document

    Set up a table to keep unlocked layers

    var layercollection = [];

    Browse layers and unlocked the layercollection table

    for (i = 0;? i ++) {}

    app.activeDocument.activeLayer = app.activeDocument.layers.itemByName (?);

    If (app.documents [0] .layers.) ([i]). Locked) == false;

    layercollection.push (Layers.itemByName ([i]))

    }

    Loop in table layercollection and paste in place

    for (i = 0; i < layercollection.length; i ++) {}

    app.activeDocument.activeLayer = app.activeDocument.layers.itemByName (tl [i]);

    app.pasteInPlace (); Dough

    }

    Can someone help me complete my script.

    Thank you!

    Did you test them all your solutions in a real world scenario?

    Theoretically, it should work this way (if one ignores that a layer is invisible, too), but even without the problem of invisible layers app.pasteInPlace () prefer to paste into the original layer, if the option "Paste remembers Layers" is checked.

    So I recommend you do the following:

    var oldPasteRem = app.clipboardPreferences.pasteRemembersLayers;
    //uncheck "Paste Remembers Layers"
    app.clipboardPreferences.pasteRemembersLayers = false;
    
    for (i = 0; i < app.activeDocument.layers.length; i++) {
    
        //Maybe the user does not want objects pasted to invisible layers:
        if(app.activeDocument.layers[i].visible == true && app.activeDocument.layers[i].locked == false) {
            app.activeDocument.activeLayer = app.activeDocument.layers[i];
            app.pasteInPlace();
        };
    };
    //Restore the old condition:
    app.clipboardPreferences.pasteRemembersLayers = oldPasteRem;
    

    Uwe

  • Loop through the list in flex 4 conclusion d buttons

    Anyone know how to completely recursively loops through the list in flex 4 by pulling the bodies of buttons.  This way I can apply my effects for buttons on the screen at the same time?

    You just create a subclass of button that has the desired effect and use it throughout your application.

    Gordon Smith

    Adobe Flex SDK team

  • loop through the list in flex 4

    I want to loop through the list and apply the following code to each button, the checkbox and the descent down in my application

    mouseOver = "animateHover ('theComponentID').

    How is that possible?

    Hello

    This should do what you want, you must add the eventlistener now your animated can be run from the th event handler.

    protected function button1_clickHandler(event:MouseEvent):void

    {

    for (var i: Number = 0; i<>

    {

    var obj:Object = this.getElementAt (i);

    If (flash.utils.getQualifiedClassName (obj) is 'spark.components::Button')

    {

    (obj as Button) .addEventListener (MouseEvent.MOUSE_OVER, onMouseOver);

    }

    If (flash.utils.getQualifiedClassName (obj) is 'spark.components::CheckBox')

    {

    (obj as CheckBox) .addEventListener (MouseEvent.MOUSE_OVER, onMouseOver);

    }

    }

    }

    private void onMouseOver(event:MouseEvent):void

    {

    animateHover (event.currentTarget);

    }

  • How to loop through DataGrid (ArrayCollection, DataProvider collection)

    I need to loop through a collection ArrayCollection DataProvider or DataGrid (not sure which is best) so that I can insert information in a database through ColdFusion.

    The data grid has three columns: ID, item and quantity.  I have a table that contains these same fields.  The DataGrid control is pre-filled with a list of items.  The user can then enter the quantity of items in the DataGrid.  I then want to store this information in my table.  In ColdFusion, I would accomplish this through CFLOOP, however, in Flex I want to loop through the data grid so that I can get all the items and the quantities that the user has updated.

    I guess I have to do a loop in ActionScript, but I don't know how to do that.  Can anyone provide a suggestion and example code?

    Thanks again!

    Lee

    If this post answers your question or assistance, please mark it as such.

    Here ya go:



    http://www.Adobe.com/2006/mxml '.
    creationComplete = "init (); » >
     
        Import mx.collections.ArrayCollection;
         
    public void init (): void {}
    var ac:ArrayCollection = new ArrayCollection([)
    {Field1: "my one - item a field", Field2: "my field two - point one"},
    {Field1: "my field one - point two", Field2: "my field two - point two"},
    {Field1: "my one - three field element", Field2: "my field two - point three"},
    ]);
    for each {(var point: Object en ac)}
    for each {(var: objet field àle point)}
    trace (Field);
    }
    }
    }
    ]]>
     

  • How to navigate through the file to the blackberry playbook using Tablet blackberry OS for Adobe Air SDK

    Hi all

    How to navigate through the file to the blackberry playbook using Tablet blackberry OS for Adobe Air SDK.

    And also I want to download this file on the server.

    Help me by providing examples of coding.

    Thanks in advance.

    With respect,

    Sébille C

    Here are some tips to help you get started.  It all depends on the terms that you use for your search.  For the first, I would use "adobe air browse file."  For the second, I start with only a variation as "adobe air download file" and then adjust according to the first results.

  • I want to loop through the data from two different tables using for loop where the query should be replaced at runtime, please help me

    I have the data into two table with the structure of similar column, I want to loop through the data in these two tables

    based on some condition and runtime that I want to put the query in loop for example, the example is given, please help me

    create table ab (a number, b varchar2 (20));

    Insert into ab

    Select rownum, rownum. "" sample "

    of the double

    connect by level < = 10

    create table bc (a number, b varchar2 (20));

    Insert into BC.

    Select rownum + 1, rownum + 1 | "" sample "

    of the double

    connect by level < = 10

    declare

    l_statement varchar2 (2000);

    Boolean bool;

    Start

    bool: = true;

    If it is true, then

    l_statement: =' select * ab ';

    on the other

    l_statement: =' select * from bc';

    end if

    I'm in execute immediate l_statement - something like that, but I don't know

    loop

    dbms_output.put_line (i.a);

    end loop;

    end;

    Something like that, but this isn't a peace of the code work.

    Try this and adapt according to your needs:

    declare

    l_statement varchar2 (2000);

    c SYS_REFCURSOR;

    l_a number;

    l_b varchar2 (20);

    Boolean bool;

    Start

    bool: = true;

    If it is true, then

    l_statement: = "select a, b, AB;

    on the other

    l_statement: = "select a, b from bc;

    end if;

    --

    Open c for l_statement;

    --

    loop

    extract the c in l_a, l_b;

    When the output c % notfound;

    dbms_output.put_line (l_a |') -' || l_b);

    end loop;

    close c;

    end;

    /

  • When I enter the "Eubacterium' infirmum text in a cell in Excel, he eats the leading". " It's killing later logic based on obtaining all text. How to repair Excel to stop eating "of text strings?

    When I enter the "Eubacterium' infirmum text in a cell in Excel, he eats the leading". "  It's killing later logic based on obtaining all text.  How to repair Excel to stop eating "of text strings?

    In Excel, an apostrophe at the beginning of a text string has a special meaning as a character of text-alignment prefix . To start a string with an apostrophe, type two of them.

Maybe you are looking for

  • Problem installing OSMac Sierra

    Went to the app store on my MacPro 2012 and downloaded the new OSSierra. He then stated the download has a corrupted file and could not be installed. When I go back to the app store it says the app (OSSierra is downloaded). How can I remove the downl

  • I lost the 'send' in my menu bar

    no idea of what I've done... sent an email to the bcc group, which was something that I did for the first time... think I have that ready for departure and I did not 'send' more... not with this e-mail or any other person.

  • HP LaserJet P2055d driver

    I use a portable 64-bit windows 10. Recently I download driver, such as listed in the list. I couldn't theabove printer. I then change to other drivers who had PostScript, I had managed to get the printer to print but only almost a quarter of the pag

  • regarding the screen lock function

    Hello I got my phone by using the "secure with PIN code. [go to control panel-> slot security screen-> screen-> Select "Secured with PIN option" lock]. Lock the phone by using the power button. Now unlock it using the power button. You could be broug

  • Could this kind of hardware run battlefield 3

    AMD ATHLON II X 2 250 DUAL CORE -Card mother BIOSTAR HDMI -4 GB DDR 3 PC3-10600 -500 GB SATA2 7200 RPM HARD DRIVE -DOUBLE LAYER DVD - RW -ATI HDMI 1080 P -6 CHANNEL DIGITAL SOUND 10/100/1000 ETHERNET -APEVIA cases AMD Phenom II X 4 965 Quad-Core 3.4