Nth occurrence match

Hi all

Using the regular Expression function corresponds to I want to match against only the nth occurrence of my regex in my input string. For the life of me I don't see how to do this perfectly. I was expecting a modifier followed an argument (n), but I just can't understand. I've been on many Perl sites and seen examples, but being is not a high-level text-based programmer, I can't translate them for LabVIEW talk.  Anyone got any ideas? Thank you in advance.

Best regards, GGT.

(Z) and {7} are the key elements.

Jim

Tags: NI Software

Similar Questions

  • Due to false positives

    Hello

    We have ID 4210 box with version 3.1 and using virtual machines to monitor and manage the area ID. We use the perl script for sending email notification whenever the event is triggered. The problem is that we receive a lot of false positives for signatures like 4001, 4003, 5366 etc how can you eliminate false positives detection.

    Thanks and greetings

    Salim

    Hello

    You could use response to threats of Cisco - who will get a stream directly from the Cisco IDS 3.X and 4.X sensors and could help is to reduce false positives.

    In a word WHAT CTR will occur a series of controls against the targets of the attack as it is the right operating system system, and in the case of windows systems, it will check the levels of Patch etc. It uses digital fingerprints NMAP and agents currently I think it's free and requires a box of windows 2000 with fast processor to work.

    The issue you'll have with this is that it increases only events using SNMP - so you should have to rely on your business to generate emails.

    It should significantly reduce your events.

    If you use CSPM, you can also set configuration notifications occur on the 1st occurrence of an event, the nth occurrence and a timer reset to reduce the number of recurring events.

    In the version IDS 4.X, you can perform a range of tuning including fireone, summary events etc. to futher reduce the generated events.

  • How to select the csv data stored in a BLOB column as if it were an external table?

    Hi all

    (Happy to be back after a while! )

    Currently I am working on a site where users should be able to load the data of csv (comma is the separator) of their client machines (APEX 3.2 application) in the Oracle 11.2.0.4.0 EE database.

    My problem is:

    I can't use an external table (for the first time in my life ) so I'm a little clueless what to do as the csv data is stored by the application of the APEX in a BLOB column, and I'm looking for an elegant way (at least SQL PL/SQL/maximization) to insert the data into the destination table (run validations by a MERGER would be the most effective way to do the job).

    I found a few examples, but I think they are too heavy and there could be a more elegant way in Oracle DB 11.2.

    Simple unit test:

    drop table CBC purge;

    drop table dst serving;

    create table src

    (myblob blob

    );

    create table dst

    (num number

    , varchar2 (6) str

    );

    Insert in src

    Select utl_raw.cast_to_raw (1; AAAAAA ;'|| Chr (10) |

    2; BATH; »

    )

    Double;

    Desired (of course) output based on the data in table SRC:

    SQL > select * DST;

    NUM STR

    ---------- ------

    1 ABDELKRIM

    2 BATH

    Does anybody know a solution for this?

    Any ideas/pointers/links/examples are welcome!

    / * WARNING: I was 'off' for about 3 months, then the Oracle - the part of my brain has become a bit "rusty and I feel it should not be so complicated as the examples I've found sofar ' * /"

    Haha, wonder about regexp is like the blind leading the blind!

    However, it's my mistake: I forgot to put the starting position setting (so 1, 2, 3,... was in fact the starting position, not the nth occurrence. duh!)

    So, it should actually be:

    select x.*
    ,      regexp_substr(x.col1, '[^;]+', 1, 1)
    ,      regexp_substr(x.col1, '[^;]+', 1, 2)
    ,      regexp_substr(x.col1, '[^;]+', 1, 3)
    ,      regexp_substr(x.col1, '[^;]+', 1, 4)
    ,      regexp_substr(x.col1, '[^;]+', 1, 5)
    ,      regexp_substr(x.col1, '[^;]+', 1, 6)
    from  src
    ,      xmltable('/a/b'
                  passing xmltype(''||replace(conv_to_clob(src.myblob), chr(10), '')||'')
                  columns
                    col1 varchar2(100) path '.') x;
    

    Note: that's assuming that all the "columns" passed in the string won't be lame.

    If one of them might be null, then:

    select x.*
    ,      regexp_substr(ltrim(x.col1, ';'), '[^;]+', 1, 1)
    ,      regexp_substr(ltrim(x.col1, ';'), '[^;]+', 1, 2)
    ,      regexp_substr(ltrim(x.col1, ';'), '[^;]+', 1, 3)
    ,      regexp_substr(ltrim(x.col1, ';'), '[^;]+', 1, 4)
    ,      regexp_substr(ltrim(x.col1, ';'), '[^;]+', 1, 5)
    ,      regexp_substr(ltrim(x.col1, ';'), '[^;]+', 1, 6)
    from   src
    ,      xmltable('/a/b'
                  passing xmltype(replace(';'||replace(conv_to_clob(src.myblob), chr(10), ';')||'', ';;', '; ;'))
                  columns
                    col1 varchar2(100) path '.') x;
    
  • Basic instr (docs/bases not clear Oracle guide) question

    Hello

    I'm obviously quite new to this, but do not understand the more generally instr function, it's just the variable 'position' that confuses me a little, and the oracle documentation and manual review of basic principles are quite vague on this issue.
    INSTR(source string, search item, [start position],[nth occurrence of search item) the function returns a number that represents the position in the string source,
    tostarting from the given starting position, where the nth occurrence of the search item
    begins
    Examples
    Example 7-127 using Position of character to look forward to find the Position of a substring

    The following example searches for the string 'Corporate Floor', starting with the third character, for the string 'or '. He returned in 'Corporate Floor' position in which the second occurrence of 'or' begins.

    See THE INSTR ("Corporate Floor', 'or', 3, 2")
    14


    Surely these things are simply wrong?

    If the research started from the starting position given in the example from the oracle documentation, the answer would be 12, 14? 3 ('r') character to the second instance of "or" is inclusive, 12 characters isn't it?

    or have I totally misunderstood?

    Thank you

    Nick

    Published by: 967660 on October 25, 2012 06:55

    Published by: 967660 on October 25, 2012 06:56

    967660 wrote:

    just confused me - what is the point of the position variable at all? Why tell it to start at the point "x" If the result will be the same no matter what?

    I think that you are still confused, the result won't be the same.

    SQL> select
      2    instr('Corporate Floor','or', 3),
      3    instr('Corporate Floor','or')
      4  from dual;
    
    INSTR('CORPORATEFLOOR','OR',3) INSTR('CORPORATEFLOOR','OR')
    ------------------------------ ----------------------------
                                 5                            2
    

    From 3 If is or at 5, from 1 position that he finds it to position 3.

  • How to retrieve a single value to an XMLTYPE

    Hello

    I have the following XML is stored in an XMLType column.

    < root >
    < abc > 1 < / abc >
    < abc > 2 < / abc >
    < root >

    How can I extract the first occurrence of/root/abc?

    Thank you and best regards,
    A

    A number like predicate will give you the nth occurrence.

    Select extractValue (XML_CLOB, ' / root/abc [1]')
    everything which

    Chris

  • Count occurrences of matched words

    All,
    Does anyone know the syntax or the algorithm to count the occurrences of matched words that separate compared cases of two tables or columns? Here is a simple example of the type of comparison, I would like to perform. I found the regexp_count function, but it only works in 11g. Unfortunately, I have Oracle 10 g. Any help would be greatly appreciated. Thank you

    i.e.

    drop table compare_matched_words;

    create table compare_matched_words)
    number of query_id,
    query_string1 varchar2 (80).
    query_string2 varchar2 (80)
    );

    insert into compare_matched_words values (1, 'oracle' 255', oracle1 255');
    insert into compare_matched_words values (2, ' larry ellison or ','larry or ');
    insert into compare_matched_words values (3, 'oracle and text', 'and');
    insert into compare_matched_words values (4, ' groups1 market share ","market share");
    insert into compare_matched_words values (5, ' larry or "," larry ellison ");
    insert into compare_matched_words values (6, 'oracle1' 255', oracle 255');

    Is not in 11g. Before that you can solve the task, you need to split QUERY_STRING1 and QUERY_STRING2 in words and then compare the words for QUERY_ID even. To split the string into words use something like:

    select  query_id,
            regexp_substr(query_string1,'\w+',1,column_value) query_string1_word
      from  compare_matched_words t,
            table(
                  cast(
                       multiset(
                                select  level
                                  from  dual
                                  connect by level <= length(regexp_replace(regexp_replace(QUERY_STRING1,'\w+','A'),'[^A]'))
                               ) as sys.OdciNumberList
                      )
                 )
    /
    SQL> /
    
               QUERY_ID QUERY_STRING1_WORD
    ------------------- -------------------
                      1 oracle
                      1 255
                      2 larry
                      2 or
                      2 ellison
                      3 oracle
                      3 and
                      3 text
                      4 market1
                      4 share
                      5 larry
    
               QUERY_ID QUERY_STRING1_WORD
    ------------------- -------------------
                      5 or
                      6 oracle1
                      6 255
    
    14 rows selected.
    
    SQL> 
    

    Now:

    select  t1.query_id,
            t1.query_string1,
            t2.query_string2,
            count(*) matchin_word_count
      from  (
             select  query_id,
                     query_string1,
                     regexp_substr(query_string1,'\w+',1,column_value) query_string1_word
               from  compare_matched_words t,
                     table(
                           cast(
                                multiset(
                                         select  level
                                            from  dual
                                           connect by level <= length(regexp_replace(regexp_replace(query_string1,'\w+','A'),'[^A]'))
                                        ) as sys.OdciNumberList
                               )
                          )
            ) t1,
            (
             select  query_id,
                     query_string2,
                     regexp_substr(query_string2,'\w+',1,column_value) query_string2_word
               from  compare_matched_words t,
                     table(
                           cast(
                                multiset(
                                         select  level
                                            from  dual
                                           connect by level <= length(regexp_replace(regexp_replace(query_string2,'\w+','A'),'[^A]'))
                                        ) as sys.OdciNumberList
                               )
                          )
            ) t2
      where t2.query_id = t1.query_id
        and t2.query_string2_word = t1.query_string1_word
      group by t1.query_id,
               t1.query_string1,
               t2.query_string2
      order by t1.query_id
    /
    
               QUERY_ID QUERY_STRING1                  QUERY_STRING2                   MATCHIN_WORD_COUNT
    ------------------- ------------------------------ ------------------------------ -------------------
                      1 oracle 255                     oracle1 255                                      1
                      2 larry or ellison               larry or                                         2
                      3 oracle and text                and                                              1
                      4 market1 share                  market share                                     1
                      5 larry or                        larry or ellison                                2
                      6 oracle1 255                    oracle 255                                       1
    
    6 rows selected.
    
    SQL> 
    

    SY.

  • search for a matching value database

    An existing database stores the results of a test like col 1 "Serial number" col 2 date etc.

    There is now an obligation of search on the serial number and to display the results associated with it (lines).

    I have the set of database tools and have begun using the vi SQL to retrieve the serial number from several Ref recordset. I'm at the point where I now need select the line corresponding to this Ref number but I was wondering if it would be better to read in the database in a table and then make a search on the serial number text search pass, get the table row where matches occur and then display the lines , or is this road very long-winded and should stick with the SQL vi?

    Thank you

    Jack

    The query SELECT * FROM tablename WHERE Serial_number = "0002" would return the entire row for each occurrence of serial number 0002. If you wanted only to pass the results, the query is SELECT * FROM tablename WHERE Serial_number = '0002' AND Status = 'Pass '.

    Do not use the column names with spaces in them!

    I've seen many references to SQL online, and there are books available. I don't have that I could recommend, however. I learned using SQL Server and a SQL expert in our IT Department

  • Hierarchy with each Member of the child's repeated occurrences

    I created a simple hierarchy in OBIEE Administration tool, as follows:

    Hierarchy.JPG

    When I create an analysis using this hierarchy, I would expect the following:

    Expected.jpg

    Instead, I'm multiple occurrences of each Member of the child, as follows. I do not know what is causing the failure, because none of these criteria, I have included in the analysis.

    Actual.jpg

    Take a look at the generated query physical if you are 100% sure of what groupping done OBIEE and from there you can find on the issue.

    You can also start by dual control key you defined (Sun and hierarchy) and, of course, that I'm sure you didn't play too much with content levels to set some strange things, but they are well positioned to match your hierarchies, right?

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

  • How to get the number of occurrences per document

    Hello

    I have a table of documents (word, pdf, excel, txt) stored in the blob column. I want the SCORE to returns the number of occurrences in each document, so I use this piece of code:

    SELECT bdt.*, score_1, DBMS_CRYPTO SCORE (1). HASH(Archivo, 3) AS cod_hash

    OF crg_ctx_archivos_recibidos bdt

    WHERE CONTAINS

    (archivo,

    ' < query >

    < textquery = grammar 'SPANISH' lang = 'CONTEXT' > DEFINESCORE (paz, OCCURRENCE * 0.1) < / textquery >

    < score datatype = "INTEGER" algorithm = "COUNT" / >

    < / query > ', 1

    ) > 0

    ORDER BY PARTITION (1) DESC;

    However, I get a maximum score of 10, but I know that one of these documents have 490 games. How can I get the exact number of matches by document?

    Thanks in advance

    PD. I am using Oracle 11.2

    All the scores at the top inside to 100, so I don't think that you will be able to make the distinction between a document with 100 matches and the other with 490.

    Can you explain what you're trying to do with this?  There may be a way to use text search to find all docs with at least 100 shots, then their post-processing to order by the real number.

  • Grep for styling the second occurrence of a Word

    Hi all

    I'm putting a dictionary for children.

    name of the bicycle

    a vehicle with two wheels in tandem, usually propelled by pedals attached to the rear wheel by a chain and have the handlebars for steering and a saddlelike seat. • Some find it faster to ride a bicycle and weaving through cars to take the bus or drive a private car.

    I managed to match the first occurrence of the bicycle to the second (underlined below) using the following grep.

    (?:^( \w+).+\r.+(\r.+)?) (\1)

    bike noun

    a vehicle with two wheels in tandem, usually propelled by pedals attached to the rear wheel by a chain and having the steering handlebars and a seat saddlelike. • some found it quicker to mount a bike and weaving through cars to take the bus or drive a private vehicle.

    This grep (that which) works as expected in the dictionary, but now I need to be able to select only the second word (in italics and in red in the example above) to be able to give him the correct character style.

    Any help would be greatly appreciated.

    Thanks in advance.

    Stephen

    GOAL!

  • regexp_replace all occurrences

    Hi all
    I use oracle 10g and am trying to use regexp_replace.

    assuming I have a code which is built by the numbers and the letter A, for example: A1A6A2.
    the need to drop the occurrences of all 'A' inside, but not the first and not the last.

    in other words, the letter A, which takes place between two numbers.

    I used the bottom of segments
    select regexp_replace('A1A6A2', '(\d)A(\d)', '\1\2')
    from dual
    
    select regexp_replace('A1A6A2', '(\d{1,})A(\d{1,})', '\1\2')
    from dual
    and got this result: A16A2

    who not complete necessary given that the result is still letter has between 6 and 2!
    is it because that the var is not scanned
    I even used it:
    select regexp_replace('A1A6A2', '(\d)A(\d)', '\1\2', 1, 0)
    from dual
    but he got the same results,

    The results is supposed to be: A162

    How can I replace all instances of the model in the source_char

    can help you with tips, advice, or even a link
    while I can understand how to regexp to find the expression pattern.

    Best regards, thanks in advance.
    Anne Marie,

    Published by: Knowledgestudent on April 26, 2012 12:08

    Hello

    I think that one thing to learn about the regexp is to know when not to use.

    Your first requirement
    "To quit the occurrences of 'A' all the interiors, but not the first not last."

    can easily reached by

    with t as (
      select 'A1A6A2' s from dual
    )
    
    select
      substr(s,1,1)
    ||replace(substr(s, 2, length(s) - 2),'A', null)
    ||substr(s, length(s) ,1)
    from t
    
    S
    A162
    

    your second reuqirement is not at all the same as the first

    "in other words, the letter A, which takes place between two numbers.

    and it's a little more complicated ;-)

    It cannot be DOE with a regexp easy IMHO. Think about it, the regular expression is the first occurrence of \dA\d, for example A1A6A2A3. To do this, replace it. The next character will be an a A, when the model will not match. So it goes for the next, the A is going to stay.

    with t as (
      select 'A1A6A2A3' s from dual
    )
    select
    regexp_replace(s,'(\d)A(\d)','\1\2')
    from t
    
    REGEXP_REPLACE(S,'(\D)A(\D)','\1\2')
    A16A23
    

    concerning

    Published by: chris227 on 26.04.2012 01:26

  • GREP nth character position

    Hello world

    My apologies in advance if this been asked a zillion times before, but no one knows how to search for a character of Nth position in a certain place, for example

    HarryPotter

    I want to choose the 6th character from left to right, the 'P '.

    In addition, no one knows the GREP code for this for BBEdit?

    Thank you very much

    GR

    Hello

    use

    . (?<>

    to match the 6th element

    Jarek

  • Problem with GREP - find only the 1st occurrence

    Hi all

    In the example below, I'm trying to find the text between pairs of characters $ .

    1.png

    Theoretically, it should work - \$\s.+?\s\$ - but in practice, he finds that the 1st instance. I can't understand why.

    It is interesting in JS, this phrase works as expected.
    I select text and run the script:

    Main();
    
    function Main() {
        var doc = app.activeDocument;
        var sel = app.selection[0];
        var contents = sel.contents;
        var match = contents.match(/\$\s.+?\s\$/g);
    }
    

    And it returns all occurrences of four:

    2.png

    What I am doing wrong?

    Thanks in advance.


    Kas

    We could improvements, adds Adobe InDesign GREP and now the character $ gets a little hackneyed. He did likewise for me (only find 1 here), but I got it to work using

    \x24\s.+\s\x24

    (where "\x24" is the hexadecimal representation of "$").

  • Find several occurrence of a dynamic string using RegExp?

    I need to find multiple instances (there can only be one) of a dynamic text. For example

    var searchForThis:String = 'hi. '

    var regEx: RegExp = \b/searchForThis/\b

    The above does actually not compile and if I remove the two \b he actually seek the word searchForThis and not salvation.

    (1) how can I configure RegExp to search for a word not only a substring that is dynamic and can find multiple occurrences as well as the index at the beginning of each event?   So, if I had the string "Hi there by there salvation once again. Where is the road"he would find two matches. He wouldn't understand road because this salvation is just a substring. I would be looking for the words

    With the next component, I find the three games in the list when I click the button of "game". It does not give you the match index, even if - depending on what you plan to do, String.replace () could work (the replacement of the game can be a string or a function that is passed to a certain number of arguments, including the index of matches).


    http://www.Adobe.com/2006/mxml"width ="400"height ="300">
       
            private var v: String = "Hi there by there Hi there Jake."
    private var re: RegExp = new RegExp ("Hi", "g");
               
    private void handleClick(e:Event):void {}
    var matches: Array = v.match (re);
    matchList.dataProvider = matches;
    }
               
    ]]>
       

       
       

Maybe you are looking for