Extraction of the bracketed text string data

I have a bit of SQL to retrieve the text in brackets at the end of a string:
WITH test_data AS
     (
     SELECT 'Joseph Bloggs (Joe) (THIS)' v1 FROM DUAL UNION ALL
      SELECT 'Robert Holnas (Bob) (THAT)' FROM DUAL UNION ALL
      SELECT 'Mary Mild (THIS)' FROM DUAL UNION ALL
      SELECT 'Jack Jill (THIS)' FROM DUAL
     )
SELECT v1
    , INSTR(v1, '(') start_bracket_pos
    , INSTR(v1, ')') end_bracket_pos
    , TRIM(SUBSTR(v1,INSTR(v1, '(')+1,INSTR(v1, ')')-INSTR(v1, '(')-1)) current_label
    , (LENGTH(v1) - LENGTH(REPLACE(v1, ')'))) / LENGTH(')') "ct_("
    , (LENGTH(v1) - LENGTH(REPLACE(v1, ')'))) / LENGTH(')') "ct_)"
  FROM test_data;
Still, it extracts data from the media at the end of the string.

I was wondering if I can change it to be able to extract the text between for example two sets of brackets - for the above test data, it would be useful to be able to extract the 'Joe' and 'Bob', but also 'CE' and 'WHO' at the end as well. It would be useful to have a column that contains the first support content and the 2nd set of content in another column.

Is there a switch that I can use for example an INSTR() to return the position of the first open bracket and the 2nd and so on?

Any advice much appreciated

Thank you

A way, using reg exp:

SQL> WITH test_data AS
  2       (
  3       SELECT 'Joseph Bloggs (Joe) (THIS)' v1 FROM DUAL UNION ALL
  4        SELECT 'Robert Holnas (Bob) (THAT)' FROM DUAL UNION ALL
  5        SELECT 'Mary Mild (THIS)' FROM DUAL UNION ALL
  6        SELECT 'Jack Jill (THIS)' FROM DUAL
  7       )
  8  SELECT v1
  9      , regexp_substr(v1,'\((.*?)\)',1,1,null,1) bracket1
 10      , regexp_substr(v1,'\((.*?)\)',1,2,null,1) bracket2
 11    FROM test_data;

V1                         BRACKET1                   BRACKET2
-------------------------- -------------------------- --------------------------
Joseph Bloggs (Joe) (THIS) Joe                        THIS
Robert Holnas (Bob) (THAT) Bob                        THAT
Mary Mild (THIS)           THIS
Jack Jill (THIS)           THIS

The regular expression find something in parentheses (the? makes not greedy, it's important.)
1 means start over from the beginning of the string.
Next number means bracket1 "first occurrence", bracket2 is "second occurrence" - you can continue with 3, 4, etc.
null value uses only the default options for reg exp (here could be option for example for sensitive cases in search).
Final 1 means that the result is the first 'group' in the reg exp - this only receives us the text in brackets and not the media themselves.

Tags: Database

Similar Questions

  • Divide the number of string data

    I have user as J1 entries. A1 through J1. A20 that I want to get the given text range 1 to 20,

    Please share me the logic

    Concerning

    Vikram Kumar P

    I would like to use the Scan of string with format set to "J1. A %d.  You will get the digital value as output.

  • the analysis of string data

    Hi all

    I got the series communation data string in this format:

    Bridge of fuse HtrPwrV VDispV/C PAO V/C DTM V/C DiffC NC
    OK VALIDATES 1.80 0.95 3.16 0.53 537 29.6
    369 647 110

    And I want to extract some value from it. I realized that they are separated with spaces between them. So I thought about transfer them into an array and then extract some lines/columns there. But I don't know how to do.

    Could you give me an idea. Or if you have a better way, then please show me!

    Thank you

    Here is a way.

  • How can I get the url query string data to a site created with the Muse? It is not module_url works in Muse.

    In my Muse created site (i.e. musesite.com), the url to the site link will be something like, www.musesite.com/homepage.html?userid=123 and I want to capture the value of username. There is documentation on the use of module_url, but documentation is vague and it's not really show in use in the Muse Awards Business Catalyst. Is there an easy way to retrieve the values of url string that does not script require extensive coding?

    Muse is strictly HTML and CSS and a little Javascript. To use URL parameters as you learn on would need a kind side Server advanced such as PHP which is out of the reach of Muse. Essentially of Muse is not the right tool, you use to achieve this.

    This works for you in Joomla because as Wordpress and they are written in PHP.

  • Extract text from a text string

    I have this text in a text field: "555-555-5555 PAUL ADRIANO 11596 MAIN ST 03/01/2013" there at - there a way for me to extract just the phone number and put in another field of own text?

    Sure. In this case, you can divide the string with the comma as a delimiter and then deal with the elements in the resulting table.

    It will look something like this:

    var myString = "702-555-5555,GASTELUM NOEL & GALLEGO-EGURROLA MARIBEL,1328 N SLOAN LN,1/4/2013";
    var items = myString.split(",");
    if (items.length==4) {
        var phoneNumber = items[0];
        var name = items[1];
        var address = items[2];
        var date = items[3]
    }
    
  • QT_TR_NOOP() macro does not mark the string for the extraction of the .ts file

    Hello

    Because I want to put all the translatable texts in one place, I defined a separate category for that. The .h file similar to below:

    #ifndef TEXTCONSTANTS_H_
    #define TEXTCONSTANTS_H_
    
    #include "qobject.h"
    
    class TextConstants : public QObject {
        Q_OBJECT
    
    public:
        static const char *SWITCH_APP;
    };
    
    #endif /* TEXTCONSTANTS_H_ */
    

    And the .cpp file similar to below:

    #include "TextConstants.h"
    
    const char *TextConstants::SWITCH_APP = QT_TR_NOOP("Switch App");
    

    Note that in the file above, I use QT_TR_NOOP() macro to mark the string given for extraction of the .ts file. This is mentioned in the documentation at https://developer.blackberry.com/native/documentation/cascades/device_platform/internationalization/....

    I then called tr (TextConstants:WITCH_APP) in a different subclass of QObject. The problem is that the text "App switch" is not extracted from the .ts file, why? If I call tr() and skip the text "App Switch" like tr ("Switch App"), this text is extracted from the .ts file. Am I missing a few things to make it work? Thank you.

    PS. I use® for QNX Momentics® IDE for BlackBerry® 10 native SDK, Version: 10.1.0, Build id: v201303191709

    Hello.

    I think you have misunderstood my suggestion.  I was only suggesting that you call the function tr() in your statement of constant ithat you posted nstead of QT_TR_NOOP(), not in other parts of your code, to see if the compiler accepts it and the chain gets extracted correctly.

    If this does not work, I'll try to track down the code of the work for the purposes of comparison.

    Sorry if I wasn't clear before.

  • 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)

  • Replace the string with the formatted text

    Hello all - I'm back to my beloved project...

    I want to replace a string by a TextSelction (formatted text) and began with the famous feature of Jang FindAndReplaceString.
    Since my replacement comes from another document (sourceDoc), I edited to targetDoc activeDoc and introduced a second document (sourceDoc).
    The replacePara actually comes from a stone where he had been placed to avoid switch backwards between the documents in a book (where to find and replace) and source documents. In another function, I learned that information on the table requires the sourceDoc must remain open.

    • Of course, everything works fine until I want to insert the replacelement:
      erase line 26 is the string
    • Given that I do not insert a string, I skip lines 28 and 29 and try try line 30
    • On line 30 DocumentSource is Document object and replacePare object TextSelection. However, sourceDoc.replacePara is not set and
    • (as a result?) line 31 past the current contents of the Clipboard.

    Of course, there is a fog around me... and I need some sunshine.

    function FindAndReplacePara (targetDoc, findString, sourceDoc, replacePara, loopMax) {
      var tr = new TextRange();
      var restoreTR, frame = 0, loopCounter = 0, replacementCounter = 0;
      var findParams = new PropVals();
      var firstPgf = targetDoc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf;
      
      tr.beg.obj = tr.end.obj = firstPgf;             //  set up the starting text range as the very beginning
      tr.beg.offset = tr.end.offset = 0;              // of the flow. We'll move straight from beginning to end.
      trSaved = tr                                    // to come back after work
    
      findParams = AllocatePropVals(2);
      
      findParams[0].propIdent.num = Constants.FS_FindText;
      findParams[0].propVal.valType = Constants.FT_String;
      findParams[0].propVal.sval = findString;
      
      findParams[1].propIdent.num = Constants.FS_FindCustomizationFlags;
      findParams[1].propVal.valType = Constants.FT_Integer;
      findParams[1].propVal.ival = Constants.FF_FIND_CONSIDER_CASE;
    
      FA_errno = Constants.FE_Success;                // errno global, to be used to track the progress of the find and replace
      tr = targetDoc.Find(tr.beg, findParams);        // and do an initial find to get started.
      
      while(FA_errno === Constants.FE_Success && loopCounter++ < 2*loopMax) { //find and replace loop as long as we keep finding
        targetDoc.TextSelection = tr;                 // set up the text range to clear the original text
        targetDoc.Clear(0);                           // clear it
        
    //    targetDoc.AddText(tr.beg, replacePara);       // insert the new text at the original beginning of the text range
    //    tr.beg.offset += replacePara.length;          //  lets jimmy the text range in memory to place it directly after
        targetDoc.TextSelection = sourceDoc.replacePara;        // paste the whole replacement paragraph
        targetDoc.Paste (0);                          // <-- Current contents of clipboard is pasted !!!!
        if(FA_errno === Constants.FE_Success) {       // increment our return counter
          replacementCounter++;
        }
        FA_errno = Constants.FE_Success;              // ...  find the next instance. We'll reset FA_errno again just in case
        tr = targetDoc.Find(tr.beg, findParams);      // something screwy happened while we were replacing text.
      }
      targetDoc.ScrollToText(trSaved);                // we're done. Restore the document to it's original area of display
      return replacementCounter;
    } // --- end FindAndReplacePara
    

    Hi Klaus,

    Thanks for the explanation. I remember something like that GetTabRange of the way back. You have been quite patient and persistent with this project, indeed.

    So, as we are dealing with ranges of text here, I think that the only simple approach is to perform a copy and paste. There is no way to save a 'formatted' in a variable. The only super precise way would be to get a data structure of each text range TextItems in the sourceDoc, then meticulously recreate every element of the targetDoc. It would be very complicated, I think, so copy and paste seems the most logical. I wonder, though, if Miss me something, because I think that maybe you would have tried already so yes (?)

    In any case, I would do something like that, from line 30 of your original code sample (code untested here):

    App. ActiveDoc = sourceDoc;

    sourceDoc.TextSelection = replacePara;

    sourceDoc.Copy (0);

    App. ActiveDoc = targetDoc;

    targetDoc.Paste (0);

    ... etc.

    Does make sense, or am I barking the wrong tree, as they say?

    Russ

  • How to convert the currency amount in a text string?

    Is there a simple way to convert a quantity of money (with a variable number of characters but always two decimal places), a text string? Currently we send UPDATED at the end of a session, but the data warehouse is only set up to accept the text values.

    We use version 9.4 of the software if it makes a difference.

    Thank you very much
    Rob

    Hi Rob.
    You can concatenate a currency with an empty string "" which translates in the text, but that would give you the currency symbol or 2 decimal places.
    for example = concatenation of & «»

    £1.50 would release 1.5. You can format these rules, but it is annoying if you have had plenty of outings like this.

    text = the concatenation of ' £' & currency & padding

    table of Pseudo-regles
    padding =
    «. 00' if Trunc (currency, 0) = currency
    '0' if Trunc (currency, 1) = currency
    "' otherwise

  • Customize the text string of response from Apple Mail

    Somehow I think that I can change a file in preferences for Apple Mail that will allow me to customize the following:

    When I reply to an e-mail message, the following text is generated automatically:

    At 07:49 on May 17, 2016, Joe Blow < [email protected] > wrote:

    However, I prefer:

    May 17, 2016, Joe wrote:

    So, I wonder if there is a settings file with something like the following in it:

    "We < date of message >, at the time of the <>message, < first > < last > < sender.address > wrote:

    .. .who I trim to be:

    "The < date message >, < first > wrote:

    The form it takes is not important because I can probably find a way to modify it to suit my intention. But, if such a settings file exists, and what is the path to the file and the name?

    I tried a Google search and come empty. Perhaps no one took never bother with this sort of thing? I would like to stop all my answers editing before sending, to get them to look the way I want.

    Thank you!

    I use El Capitan.

    Have you looked at Quotefix?

    https://github.com/robertklep/QuoteFixforMac

  • Firefox crashes when I try to enter data into the URL text box.

    Firefox crashes whenever I try to add data in the URL text box or the text box search in the toolbar. When it freezes it also locks on the Task Manager. However, the other routines running continue to run. I've disabled all my antivirus. always freezes. I left the Task Manager; always freezes and can't open the Task Manager. While it freezes, it is still possible to reduce the window of Firefox or resize it. If I try to kill him, I get a message "no answer."

    Start Firefox in Firefox to solve the issues in Safe Mode to check if one of the extensions or if hardware acceleration is the cause of the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > appearance/themes).

  • How to access the data in the row (text of children) in a pragmatic control tree?

    In LabVIEW 2010, I entered the data in row a tree with pragmatism control using the Add item and providing the child text table and the child tag for the line. When a row in the tree control is selected, I can get the line label in the Value property of the tree. But how do I access the data in the child text table when the line is selected? I can't seem to find a tree control property or method which will return data back.

    What I'm trying to do is: once a line in a tree is selected and a button is pressed, if the line tag is valid, I want to transfer all the data in row in another tree the same formatting. For this I need the data for the tree line and the line that was selected. I don't find a way to get access to these data of the line when it was composed in the tree.

    Can someone tell me how to access pragmatically the child text or row data in a tree control from a selected line in the tree? I have the label of the line, but how do I access data?

    Thank you for your help.

    Looking through numerous examples, I found how to do this using the properties ActiveItemRow and ActiveColNum, but I can't find these documented properties anywhere using LabVIEW. Even research through aid could not do anything about them.

    Where these important parameters are documented?

    Why they do not appear in the help?

    Are there other ways to access the data in the row (child text) form a selected line in a tree control?

  • Convert a Boolean trigger in the text string

    Hello

    I would like to know if it is possible to convert some text buttons in a single variable text string.

    Let me try to explain:

    I have 3 buttons: Simulation, send, Quit

    Now, I want to use a case structure, in which it is possible to switch between these 3 options.

    So if you press the button for a second, I would have a string of text with the text: send.

    If I press Quit, having to turn into Quit, text string even if I can connect this string to the structure of the case.

    Is this possible? It sounds easy, but I can't figure out how do it in a simple way.

    How I did it: Boolean convert (0.1), these values multiplied by a number,

    for example (1,2,3), but to make a deal with (1,2,3) structure and write the right text in a text string.

    But I think it can be done much easier, isn't it?

    Thank you!

    Hello

    Check the attached VI. I think this should help you. The mechanical action of the buttons are "switch until released. You can change it according to your requirement.

    The second example uses the Structure of the event.

    Kind regards
    Nitz

    (Bravo to give good answers, mark it as a solution if your problem is resolved)

  • How to get the 'selected text '? leave a string

    If I highlight text in a text string, I want to be able to copy it to the Clipboard.

    I have already created an event that uses the Application of reference to 'write the Clipboard' now I need to give it the selected text.

    How do I do that?

    Here's a way to do it.

    Ben64

  • Text string in array of integers - with law enforcement in the text string-

    Hello

    I have a text string containing the measurement frameworks.

    I want to place each image in a first time 0, 11 x 11 array (with the same order in the text file).

    In the figure below, I tried to convert it to a table, but the table only contains the first "column" in the text file.

    Any suggestions?

    Crows is right, your channel is very dirty, with a variable number of spaces, lines starting with spaces and space + newline delimiter.

    In such cases, I like "scan of the channels for tokens", because it can automatically enter into identical consecutive separators in a single. Here's a quick example.

    Your lines are of variable length, a 2D picture seems inappropriate, because all rows have the same number of elements. For example, consider a table 1 d of clusters containing the tables 1 d.

    (Of course, it would be cool "worksheet in table string" could deal directly with identical consecutive separators as found here, so thank you for supporting my idea.) He deserves more than 24 voice )

Maybe you are looking for

  • Finder crashing on macOS Sierra

    I have a late 2009 iMac Core2 3.33 GHz, 8 GB RAM processor. After the installation of macOS Sierra, Finder crashes constantly on me. I have to restart about five times a day. Get beach balls when you click on an external drive or a folder. Get beach

  • Too late to correct the episode URL?

    I have a problem with a podcast episode, I found out a week later the episode URL was wrong. I corrected the link in the podcast codes. But he is still unable to download podcast software. Is it too late to correct the podcast URL when the subscriber

  • Pavilion g6 2305tx: internal microphone problem for the note book!

    my microphone internal books sometime works nut some tim does not althgu windows still detects it as its IDT card driver does not work normally. Should I have to replace my internal mic and where I find hp original pieces in Bangladesh.I Com, these A

  • How can I activate my touch Pad? a light is on and the touch pad does not work

    I have a Toshiba laptop and the touchpad equipped with a bright power who insists to stay on and do not let me use the touch pad. How to turn off the light or enable the touchpad please Thanks in advance if you can help R

  • compress columns of type blob in a directory and retrieve the zip file in the APEX

    Hi allI have a requirement which is,I have a table that has a blob column I want to save all the records of the BLOB in the table in a ZIP compressed in a directory.Then with I have to go get this zipped file in directory and save in my local compute