meaning of the given regular expression

Hi all
I want to know how the regular expression in the following query.

SELECT UNIQUE REGEXP_REPLACE (catalog_url, ' http:// (\ [^ /-] +). * ', '\1')
OF oe.product_information;

Here I put spaces for ease of understanding.
Soni

Published by: sonidba on February 5, 2010 12:28

Published by: sonidba on February 5, 2010 12:30

sonidba wrote:
Thanks for your reply. I am knowing the answer only. But not how. What does '\1' referred to here in the request. Someone at - it the answer?

Published by: sonidba on February 5, 2010 13:04

\1 is a backreference.

In the REGEXP_REPLACE function (catalog_url, ' http:// ([^ /] +). * ', '\1') there is a section of the chain of research in parentheses. \1 refers to the found value that corresponds to that subexpression. If you had several subexpressions in parentheses then you may have several backreferences.

Tags: Database

Similar Questions

  • the simple regular expression problem

    Hello

    I need assistance with regular expressions. I have a situation when I need to get data from one table to the other and I think that my problem can be solved using REG EXP, but I don't know how to use them properly.


    I need to separate fileld varchar2 which is basically number/number in 2 separate number fields
     
    
    
    CREATE TABLE tst (CODE VARCHAR2(10)); 
    
    INSERT INTO tst VALUES('10/15'); 
    INSERT INTO tst VALUES('13/12'); 
    INSERT INTO tst VALUES('30'); 
    INSERT INTO tst VALUES('15'); 
    
    CREATE TABLE tst2 (po NUMBER, co NUMBER); 
    I need to get the code in the co and po columns. I think the result should look something like this, but:
     
    
    INSERT INTO tst2 
    SELECT regexp_substr(CODE 'something here to get the number before /') AS po, 
           regexpr_substr(CODE 'something here to get number after') AS co 
    FROM tst;   
    Any help appreciated

    Agree with the above,

    However, if you really want to know how to do with regular expressions you can do it like this...

    SQL> select regexp_substr('10/15','[^/]+',1,1) from dual;
    
    RE
    --
    10
    
    SQL> select regexp_substr('10/15','[^/]+',1,2) from dual;
    
    RE
    --
    15
    
  • The match regular expression or pattern

    I'm in big trouble to the extraction of results of a string of serial port.
    I get a report through connectio series of some devices. It looks like this:

                                        Plane 1 Angle 1 Plane 2 Angle 2 In
    
         RotorID      rpm            [g·mm]    [°]    [g·mm]    [°]  Tol
                              1964.7     0.145999  201.6 0.151779  346.5 Y
                              2014.5     0.156608  197.6 0.139722  340.9 Y
             ealon ok     2012.1     0.143454  199.8 0.150243  344.6 Y
             ealon nok    2023.3    0.430547  217.7 0.833347  313.3 Y
             DN-3259824_001  2135.9 0.305822  246.2 0.296502  305.2 Y
             DN-3259824_002  2051.4 0.324227  241.1 0.327651  299.0 Y
             DN-3259824_020  2045.9 0.139268  150.2 0.281890   21.6 Y
    

    I can't separate the data with spaces, because sometimes there is no "RotorID" so that all data is moved to the left.
    There are still 7 columns. RotorID is sometimes empty sometimes that he composed characters and numbers. I never know its length. Other data are still present and separated with space.

    Can you help me please.

    If you want to use a regular exprission.

  • Regular expression help please. (extraction of a subset of the string between two markers)

    I haven't used regular expressions before, and I can't find a regular expression to extract a subset of the string between two markers.

    The chain;

    Stuff of header I want
    Stuff of header I want
    Stuff of header I want

    Stuff of header I want
    Stuff of header I want
    Stuff of header I want

    6 ERRORS
                         
    Info I want to line 1
    Info I want line 2
    Info I want line 3
    Info I want to line 4
    Info I want to line 5
    Info I want line 6
    END_ERRORS

    From the string above (it is read from a text file), I try to extract the subset of string between ERRORS 6 and END_ERRORS. The number of errors (6 in this case) can be any number from 1 to 32, and the number of lines I want to extract will correspond with this number. I can provide this number of a caller VI if necessary.

    My current solution, which works, but is not very elegant;

    (1) using Match Regular Expression for the return of the string after you have synchronized the 6 ERRORS

    (2) uses the Regular Expression matches to return all characters before game END_ERRORS of the string returned by (1)

    Is there a way this can be accomplished using 1 Regular Expression Match? If so someone could suggest how, as well as an explanation of the work of the given regular expression.

    Thank you very much

    Alan

    I used a character class to catch any word or whitespace characters.  This put inside parentheses a substring matching the criteria that you can get by developing the node for regular expression matching.  The \d matches the numbers and the two * s repetition of the previous term.  So, \d* will find the '6', as well as "123456".

  • Looking for the character "$" in a regular expression

    I try to use the vi "Regular Expression to Match", but what I'm trying to find is a dollar sign followed by a space.

    Using the slash codes allows me to specify a whitespace character (\s) but I can't find how to specify the $.

    I tried \x24 and \36 try hex and decimal ASCII representations, but no luck, I tried to put the $ hooks - but which doesn't work either.

    Everything I try, the $ is interpreted as a command rather than the search term.

    I used to use model game (legacy code) and the search term "$\s*$ ' worked - now need to use regex that I need to feed in some other matches this regex only can do - except for the dollar (if only I worked in the good old UK £!)

    Any ideas out there?

    Thank you

    I think that we must work...

    \\$\s[\n\r]

    seems to do the trick

  • Analyze the Mac address with the regular expression matching

    Hello world

    I have a problem with the function of regular expression matching,

    I try to analyse the response both a query arp - a 192.168.0.15 to retrieve the MAC address of the remote IP address, I used the following regular expression: ^ ([0-9a-fA-F]{2}[:-]){5}([0-9a-fA-F]{2})$

    I wonder why should I do a subset of the first string to extract only the part of the MAC address. The regular Expression function is not able to recognize the regular expression directly in the middle of a string?

    I only works when I extracted the subset of tring right as in the picture below.

    Thanks for your replies.

    Get rid of the "^" at the beginning of your regular expression. You are ordering him to find the model at the beginning of the string.

  • The regular expression problem

    Dear friends,

    In my script I have some sections that test the contents of an edit field before it is processed further.

    Perfectly things like the following:

    var re_Def = /#[A-Za-z][A-Za-z0-9_]+/;          // valid variable name ?
    items = ["#correct", "notcorrect", "#This_is4", "#thisIs", "@something", "#ALLOK", "", ];
    // search    0            -1          -1!!        -1!!          -1        -1!!     -1      <--- incorrect method
    // test    true         false         true        true        false       true    false    <--- correct method
    for (var j = 0; j < items.length; j++) {
      var item = items[j];
      alert ("'" + item + "' ==> " +  item.search(re_Def) + "\n" + re_Def.test(item));
    }
    var re_Def = /(\[ROW +\d+\]|\[COL +\d+\]|\[CELL +\d+, +\d+\]|Left *\(\d*\)|Right *\(\d*\)|Above *\(\d*\)|Below *\(\d*\))/;
    items = ["[ROW 17]", "[Row n]", "[ROW n]", "[CELL 3, 9]", "[CELL 3 9]", "Abbove()", "Right(3)"];
    // result  true        false      false         true         false        false         true    
    for (var j = 0; j < items.length; j++) {
      alert ("'" + items[j] + "' ==> " +  re_Def.test(items[j]));
    }
    

    But what follows always returns false, independly of the content of the string element:

    var re_Def = /{[EFJ]\d*}|{I}/;    // valid format def?
    var item = "{E27}";
    var result = re_Def.test(item);
    alert (result);                   // false !!
    

    RegEx buddy told me, that
    -l' REGULAR expression is correct
    -the result must be true, not false

    -The verbose definition of the RegEx is:
    Match is the following regular expression (attempting the next alternative only if this one fails) "{\d* [EYF]}."
    Match the character "{" literally "{}".
    Match a single character present in the list "J" "[EYF]."
    Match a single digit 0. 9 paper"\d*»
    Between zero and unlimited times, as many times as possible, giving as needed (greedy) «*»
    Match the character "}" literally "}".
    Or match number 2 below (the entire match attempt fails if it cannot match) regular expression "{i}".
    Match the characters "{i}" literally "{i}".

    Typo unrecognized? Test the faulty method?

    Results are fake, as soon as I use the list of characters []] - but look at the first block of code: there are also lists of character they are treated properly.

    The braces in the regular expression must be escaped to be taken literally:

    var re_Def = /\{[EFJ]\d*\}/;
    

    Kind regards

    JoH

  • regexp_substr: a regular expression for the separate comma operator of witn of string literals IN

    The following regular expression separates simple values separated by commas (SELECT regexp_substr (: pCsv,'[^,] +', 1, level) FROM DUAL CONNECT BY regexp_substr (: pCsv, ' [^,] +', 1, level) IS NOT NULL); Exampple: 300100033146068, 300100033146071, 300100033146079 returns 300100033146068 300100033146071 300100033146079

    This works very well if we use the regex with SQL IN operator select * from mytable where t.mycolumn IN (SELECT regexp_substr (: pCsv,'[^,] +', 1, level) FROM DUAL CONNECT BY regexp_substr (: pCsv, ' [^,] +', 1, level) IS NOT NULL);

    But this query does not work if the comma-separated value is a single literal string 'one', 'two', 'three '.

    Thanks for your reply. my request was mainly on regexp_substr.  Need to request was simple: any table with a column of varchar type can be used. Next time I'll give you an example.

    All ways working answer for my question is is SELECT regexp_substr (: pCsv,'[^, "] +', 1, level) FROM DUAL CONNECT BY regexp_substr (: pCsv, ' [^,"] +', 1, level) IS NOT NULL

  • Form validation helps with the regular Expression [a-zA-Z]

    I'm trying to use the regular expression [a-zA-Z] to allow only upper or lowercase WITHOUT SPACES. With the help of [a-zA-Z] allows space and numbers.

    Could someone give me a point in the right direction?

    Thank you!

    RGNelson wrote:

    I'm trying to use the regular expression [a-zA-Z] to allow only upper or lowercase WITHOUT SPACES. With the help of [a-zA-Z] allows space and numbers.

    Could someone give me a point in the right direction?

    Please try with the following regular expression, which should work for text entry fields 'a line' well standard.

    ^ [A-Za-z] + $

    See you soon,.

    Günter

  • Regular expressions in the APEX

    I am using the following regular expression ^ [\w\s]+?$, but it does not work in APEX.] I want to validate a field for not accepting anything but the line of underscores, spaces and alphabetic characters.

    Try to use POSIX character classes:

    ^[[:alpha:][:space:]_]+?$
    

    Note that you must always provide at least the following information when you ask a question:

    -APEX version
    -Edition and version DB
    -Web server architecture (EPG, SST or APEX listener)
    -The browsers used
    -Theme used
    -Models

  • The regular Expression disorder

    Hello everyone, happy holidays.

    I create a component in an application that is similar to the function of Facebook's "News Feed". This feature lists the rows of a database that can contain 'special' text to be converted to HTML. Note: I'm store "special text" in the database instead of the HTML real to save space in the database where the object name is very long.

    Here's what I'm trying to do:

    In the database a record might look like this:
    12/25/06 [user: 253] John Smith [a] connected.

    When I display the table I want to convert to the following:
    12/25/06 < a href = "user_info.cfm? userId = 253" > logged in on John Smith < /a >.

    I was able to create the following regular expression, which does a good job of converting the text to a link, but I am unable to get the uniqueID (253) of the string. Note: The Description is the name of the column is being processed.

    < CFSET = temp ReReplace (Description,'-[user:.------] "," < a href = "user_info.cfm? userID = 253" > ', 'ALL') >
    < CFSET = temp ReReplace (temp,'\ [/ a\]', '< /a >', 'ALL') >

    Is there a way I can convert the string into a regular expression? Also, how can I get the number value after the colon (:) and insert it in the replacement string?)

    In addition, to complicate things, the string can have multiple instances of "special text". For example:
    12/25/06 [user: 253] John Smith [a] changed account [user: 262] Captain Picard [a]

    Thanks for your help!

    The (. *) part of your regex can capture more than desired for the following user ID.

    Maybe this will do as you wish.

    -tom-

  • regular expression: an integer in the range 0.100

    What is the best regular expression to satisfy the need:
    (1) input string must be whole, the minimum value is 0, the maximum value is 100, no other symbols are allowed in the channel, no comma without a space.

    The example data:
    with T as 
    (select '-1' str from dual --not ok
    union
    select '0' str from dual --ok
    union
    select '1' str from dual --ok
    union
    select '100' str from dua --ok
    union
    select '1000' str from dual-- --not ok
    union
    select '101' str from dual --not ok
    union
    select '10.1' str from dual --not ok
    union
    select '10,1' str from dual --not ok
    union
    select 'a' str from dual --not ok)
    select * from T
    where regexp_like(str,'^[[:digit:]]{0,3}$');

    Hello

    I think you hit the key to this solution; using regular expressions, it is better to make a special case of '100'.

    You accept the numbers 1 and 2 digits that begin with '0'. would be unwise to accept 3 digit like '007' numbers, too?
    Here's a regex solution that makes and also an inelegant way to achieve the same results without regular expressions:

    SELECT     ROWNUM
    ,     str
    ,     CASE
              WHEN  REGEXP_LIKE ( str
                          , '^'          || -- Beginning of string
                            '('          || -- number, which is either
                              '(100)'     || --     100
                            '|'          || -- or
                              '(0?'     || --     optional leading 0
                              '\d{1,2})'|| --     2 digits
                            ')'          || -- end number
                            '$'             -- End of string
                          )
              THEN  'Okay'
         END     AS regexp
    ,     CASE
              WHEN  LENGTH (str)     <= 3
              AND   TRANSLATE ( str
                        , 'X0123456789'
                        , 'X'
                        )     IS NULL
              AND   LPAD ( str
                      , 3
                      , '0'
                      )          <= '100'
              THEN  'Okay'
         END     AS non_regexp
    FROM     t
    ;
    

    Output:

        ROWNUM STR  REGE NON_
    ---------- ---- ---- ----
             1 -1
             2 0    Okay Okay
             3 007  Okay Okay
             4 08   Okay Okay
             5 1    Okay Okay
             6 10.1
             7 100  Okay Okay
             8 1000
             9 101
            10 999
            11 a
            12
    

    I added these lines to the sample data:

    union
    select null str from dual
    union
    select '007' str from dual
    union
    select '08' str from dual
    
  • Using the regular expression!

    Hi all!


    I tried to get the right regular expression to parse the database link in scripts.
    For example

    Select 'X' from the double where REGEXP_LIKE (' select * from [email protected] myalias; ',' ([[: alnum:]\:._]+)(@)([[:alnum:]\:._]+]])', 'i')


    works fine but I don't want to return only DatabaseLinks which would include the lowercase characters... If I use this one:

    Select 'X' from the double where REGEXP_LIKE (' select * from [email protected] myalias; ',' ([[: alnum:]------:. _] +) (@) (. * [[: lower:]]. *) ([[: white:] |])) [[: space:]] | ; | /){1}' , 'i')
    It always returns true, because there are a few tiny characters after my DBLINK. Anyone know how to make in a way that I return true if the dblink itself contains lowercase characters?

    Thank you
    DOM

    Published by: user11846374 on 2009-08-31 12:22

    If all characters are uppercase, then return false. If there is at least 1 character lowercase, return true.

    What is

    SQL>  with t as (
     select '[email protected]' txt from dual union all
     select 'dual@DBLINK' txt from dual union all
     select 'dual@DBLInK' txt from dual union all
     select '[email protected]' from dual union all
     select '[email protected]' from dual union all
     select 'select * from [email protected] alias' from dual union all
     select 'select * from [email protected] alias' from dual union all
     select 'select * from [email protected] alias' from dual
    )
    --
    --
    select t.*,
           case
            when regexp_like (txt,
                              '@(\w*[[:lower:]]|\w*\.\w*[[:lower:]])')
            then
             'TRUE'
            else
             'FALSE'
           end
            c
    from t
    /
    TXT                                C
    ---------------------------------- -----
    [email protected]                     FALSE
    dual@DBLINK                        FALSE
    dual@DBLInK                        TRUE
    [email protected]                     TRUE
    [email protected]                     TRUE
    select * from [email protected] alias TRUE
    select * from [email protected] alias TRUE
    select * from [email protected] alias FALSE
    
    8 rows selected.
    
  • Use matching of regular expressions to search for parentheses

    Hi all

    I am currently looking for a particular pattern in a string, I can't display the exact string, but say its something like that.        corresponds to regular_pattern (5000): 0

    I'm also looking for the a different model at the same time, so I have to use the corresponding regular expression and the | function.  I can't understand how to match this model because the regular expression function allows parentheses unless I put them in the legs, and that does not help me for this.

    Any advice?

    Thank you

    Matt

    Have you tried to escape the bracket?

  • Multiline - Regular Expression Match string

    I'm trying to understand the format of a regular expression to pull select off multi-line string lines and fill in these lines as the individual elements of an array of strings using regular expressions to Match. The total length of the multiline string may vary as well as the text in the string. The string can contain letters, numbers and special characters. I've attached an example VI. In the example of VI, I want to only return lines starting by "device #" in the table. The number of lines starting by "device #" can vary, but I want to capture them all.

    Or is there a better functioning to be used instead of the corresponding regular Expression that will give me the desired result?

    aaronb wrote:

    I'm trying to understand the format of a regular expression to pull select off multi-line string lines and fill in these lines as the individual elements of an array of strings using regular expressions to Match. The total length of the multiline string may vary as well as the text in the string. The string can contain letters, numbers and special characters. I've attached an example VI. In the example of VI, I want to only return lines starting by "device #" in the table. The number of lines starting by "device #" can vary, but I want to capture them all.

    Or is there a better functioning to be used instead of the corresponding regular Expression that will give me the desired result?

    Corresponding regular expression works well for this.

    Ben64

Maybe you are looking for