REGEXP_LIKE help

create table t
( part_number varchar2(255)
)
/


insert into t values('V1ABC')
/
insert intot values ('ABC-12V')
/


commit;


select * from t where REGEXP_LIKE(part_number, '(^V*[A-Z])*+$');


PART_NUMBER
-------------
V1ABC
ABC-12V


Must return only V1ABC

With the help of Oracle 11 g R2.

Hello

"In Oracle regular expressions," * "(asterisk) does not mean"any character. " That means "before it can occur 0 or 1 times.  The wild card for any character in Oracle regular expressions is '. '. (dot).  So, if you want to have

  • 'V' at the beginning of the string, followed
  • any character, followed by
  • number any letters, from A to Z, followed
  • any character at the end of the string

Here's a way to encode:

WHERE REGEXP_LIKE (part_number

, '^V'      || -'V' at the beginning of the string

'.'       || -any character

'[A-Z]*'  || -any number of uppercase letters a Z throguh

'. $' - any character at the end of the string

)

or, more concisely,.

WHERE REGEXP_LIKE (part_number
, '^V.[A-Z]*.$'
)

Tags: Database

Similar Questions

  • REGEXP_LIKE help literal single quote

    I'm writing a check constraint to validate e-mail addresses which may include an apostrophe in the email address. Like joe.o'[email protected]. Here is my sample configuration:
    create table emails
    ( email_address varchar2(150)
    )
    /
    
    insert into emails values('[email protected]') ;
    insert into emails values('[email protected]') ;
    insert into emails values('joey.o''[email protected]') ;
    
    commit;
    
    sql> select * from emails;
    
    EMAIL_ADDRESS
    -------------------------------------------------
    [email protected]
    [email protected]
    joey.o'[email protected]
    
    alter table emails add constraint email_address_format_ck 
        CHECK ( REGEXP_LIKE ( email_address, '^[a-z0-9._%-]\'?+@[a-z0-9._%-]+\.mil$','c'));
        
    ERROR at line 2:
    ORA-00911: invalid character
    He dislikes *------'? *

    My understanding is that this means one or more of the single quotes. Does anyone know the correct syntax to accept apostrophes?

    Hello

    chris227 wrote:
    In addition to the detailed information given by Frank, I would add a thought on the?.
    I think that the intention of the? subsequently is that there should be only one or none "."

    Good point!

    So it could take into account

    select * from emails
    where
    REGEXP_LIKE ( email_address, '^[a-z0-9._%-]+['']?[a-z0-9._%-]+@[a-z0-9._%-]+\.mil$','c')
    

    That exceeded that, if there is a single quotation mark, should not be the first character, and must not enter immediately before the "@".
    It also requires that it is at least 2 characters before the "@" when there is no single quote. To allow only 1 before the "@":

    SELECT     *
    FROM     emails
    WHERE     REGEXP_LIKE ( email_address
                  , '^([a-z0-9._%-]+''?)?[a-z0-9._%-]+@[a-z0-9._%-]+\.mil$'
                  , 'c'
                  )
    ;
    

    The single quotation mark didn't need to be in square brackets.

  • REGEXP_LIKE statement help

    Hello Experts

    I have a little problem to solve the problem with REGEXP_LIKE as shown below.

    All records are giving me the result desired, except the last in alph and digital and between the two spaces.

    Can I please have the solution please. I tried with INSTR, but it does not work too.

    Thanks in advance

    Rajesh


    WITH T AS
    (SELECT '$000 444 888' STUDENT_ID FROM DUAL UNION ALL)
    SELECT ' ^ ^ ^ ' STUDENT_ID FROM DUAL UNION ALL
    SELECT "ABCDEFGH &' DOUBLE UNION ALL STUDENT_ID"
    SELECT '! @ ' STUDENT_ID FROM DUAL UNION ALL
    SELECT ' 123456 * 891' STUDENT_ID FROM DUAL UNION ALL
    SELECT "AAA 77BBBBB" DOUBLE STUDENT_ID
    )
    SELECT student_id FROM T
    IF not REGEXP_LIKE (trim (STUDENT_ID), ' ^ [[: alnum:]] * $')

    Rb2000rb65 wrote:
    Any help on this please.

    You won't get much help unless you clearly explain the issue. Sven W. gave you the solution:

    IF not REGEXP_LIKE (STUDENT_ID, ' ^ [[: alnum:]] * $"")

    SQL> WITH T AS
      2  (SELECT '000 444$888' STUDENT_ID FROM DUAL UNION ALL
      3  SELECT '^^^^^^^^^^ ' STUDENT_ID FROM DUAL UNION ALL
      4  SELECT 'ABCDEFGH&' STUDENT_ID FROM DUAL UNION ALL
      5  SELECT '!@@@@@@@ ' STUDENT_ID FROM DUAL UNION ALL
      6  SELECT '123456*891 ' STUDENT_ID FROM DUAL UNION ALL
      7  SELECT 'AAA 77BBBBB ' STUDENT_ID FROM DUAL
      8  )
      9  SELECT student_id FROM T
     10  WHERE not REGEXP_LIKE(trim(STUDENT_ID), '^[[:alnum:] ]*$')
     11  /
    
    STUDENT_ID
    ------------
    000 444$888
    ^^^^^^^^^^
    ABCDEFGH&
    !@@@@@@@
    123456*891
    
    SQL> 
    

    So if it's still not good for you, you need to explain why.

    SY.

  • Help REGEXP_LIKE

    Hello

    Browsed the web looking for assistance using the syntax REGEXP_LIKE. Did not have a precise answer, but I think that I wrote my own correct and just wanted to get validated by other users.


    Running Oracle 10.2

    Sample data:
    create table test(data varchar2(10));
        insert into test values('01W00012');
        insert into test values('50321070');
        insert into test values('A1391010');
        insert into test values('ZZ260010');
        insert into test values('29374C01');
        insert into test values('A938523A');
        insert into test values('23W48AC3');
        insert into test values('DKFUGHCK');
        insert into test values('09W00032');
        insert into test values('94857283');
        insert into test values('AB-29348');
        insert into test values('98W-8923');
        insert into test values('0AW00005');
        insert into test values('04300W05');
        commit;
    What I'm doing:
    I have a table that contains millions of work orders. They are all of length 8. I want to find all the good work where the first 2 characters are a number only, the third character is a 'W' and the last 5 characters are only numbers. Another thing I want to throw. I think that I came up with an expression of work... but I'm always hesitant when he runs against millions of rows. That's what I did:
    select * from test
        where regexp_like(data, '(^[0-9]{2}W{1}[[:digit:]]{5})');
    There are has exactly 2 occurrences of room above that match the criteria that I try to answer.
    This expression is correctly written?

    Any help would be appreciated... reg expressions always make my turn head :(

    Hello

    dvsoukup wrote:
    Running Oracle 10.2

    Samples:...

    Thanks for posting this; It is really useful!

    What I'm doing:
    I have a table that contains millions of work orders. They are all of length 8. I want to find all the good work where the first 2 characters are a number only, the third character is a 'W' and the last 5 characters are only numbers. Another thing I want to throw. I think that I came up with an expression of work... but I'm always hesitant when he runs against millions of rows. That's what I did:

    select * from test
    where regexp_like(data, '(^[0-9]{2}W{1}[[:digit:]]{5})');
    

    There are has exactly 2 occurrences of room above that match the criteria that I try to answer.
    This expression is correctly written?

    Yes, it's a good regular expression. However, one very important thing about regular expressions is that you should only use the when you actually need. In this case, you can get the results you want more effectively and at least as easily, without regular expressions. Here's one way:

    SELECT  *
    FROM     test
    WHERE   TRANSLATE ( data
                , '012345678'
                , '999999999'
                )          = '99W99999'
    ;
    

    It will be more effective than the use of REGEXP_LIKE, and it seems that efficiency is important in this case.

    If you really want to use a regular expression, there are a few things you can do to make it more clear. (With regular expressions, nothing overlooked.)
    (a) If you are sure that the data is always exactly 8 characters, then you don't need the ^ anchor at the beginning. If you want the regular expression to verify that the length is 8 characters, then keep the ^ anchor at the beginning, but also, to use an anchor $ at the end, as in the example below. As you posted it, the expression is TRUE when data are greater of 8 characters, as long the first 8 characters fit the pattern.
    (b) [0-9] is equivalent to [[: digit:]]. Either it's good, but I find it confusing to use both in the same expression. Use one or the other in both places.
    (c) {1} is the default value. I would say just 'W' instead of 'W {1} '.
    (d) you don't need parentheses in this expression. If parentheses are not required, but they improve the clarity, then it's OK to include them. In this case, I don't think they add anything.

    There are has exactly 2 occurrences of room above that match the criteria that I try to answer.

    It helps if you post exactly what results you want. For example:

    DATA
    ----------
    01W00012
    09W00032
    

    In this case, I found your description very clear, but it does not hurt to post actual results anyway.

    This expression is correctly written?

    You can consider writing this way, especially if you think you'll need to debug:

    SELECT  *
    FROM      test
    WHERE      REGEXP_LIKE ( data
                  , '^'          || -- beginning of string
                    '[0-9]{2}'     || -- 2 digits
                    'W'          || -- a capital W
                    '[0-9]{5}'     || -- 5 more digits
                    '$'             -- end of string
                  )
    ;
    

    As previously mentioned, you only need the ^ and $ if you are not sure that all the strings are exactly 8 characters.

    ... reg expressions always make my head spin

    All the more reason to use TRANSLATE.

    Published by: Frank Kulash, 26 July 2012 14:42

  • help of query using regexp_like

    kindly help me on this
    DECLARE
        STRING1  VARCHAR2(1000) :='NOT  (   VIP5';
        BEGIN
    
          if  regexp_like(string1 ,'NOT  \(* VIP5')  then
                 dbms_output.put_line('string1 is correct');
                     dbms_output.PUT_LINE(STRING1);
          end if;
        END;
    problem is that string1 can be
     'NOT ( VIP5  '
       OR  can be                                   NOT     (          VIP5'
    It is between NO AND VIP5 media will be there with spaces or no spaces

    so help me out

    S

    Published by: oraclehema on March 1st, 2011 03:38

    Maybe this?

    REGEXP_LIKE
    ( t_string
    , 'NOT[[:space:]]*(\(*[[:space:]]*)*VIP5'
    )
    

    It is always helpful if you post the requirements first :)

  • Help with Regexp_like

    Hi all

    I need help with regexp_like.

    Oracle version: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi

    create table test_regexp (str varchar2 (100));

    insert into test_regexp values ('123');

    insert into test_regexp values ('456A');

    insert into test_regexp values ('987654");

    insert into test_regexp values ('A12 34 ZZZ');

    insert into test_regexp values ('743');

    insert into test_regexp values ('ABC');

    Expected results
    ****************

    STR
    ****
    123

    987654

    743

    The search string must be only numbers and spaces, spaces can be anywhere (beginning, middle or end of string), search string must not have anty characters or special characters.

    Thanks in advance
    Rambeau

    Hello
    Try the following:

    Select *.
    of test_regexp
    where regexp_like (CBC,'^ [0-9] + ([0-9] +) $');

    or
    Select *.
    of test_regexp
    where regexp_like (CBC,'^ ([[: digit:]] |)) [[: white:]] | [[: digit :]])]] +$');

    Published by: jojo on December 2, 2010 12:09

    Published by: jojo on December 2, 2010 12:11

  • REGEXP_LIKE sql help...

    I have a first_name column in my table of students with the following characteristics:

    REDA
    Kris
    Tanvi
    Shweta
    Rajendra
    Kapil
    Vipin
    Sandeep

    Now I'm trying to use the regexp_like function to find the names that begin the letter s and end with the letter p, but I am not able to achieve that I provided here my request please help:

    Select first_name
    the student
    where regexp_like (name, ' ^ sp$ ');

    Concerning
    Rahul

    Mac_Freak_Rahul wrote:
    where regexp_like (name, ' ^ sp$ ');

    Describe your regular expression is to find the string "sp". You do not include buildings for characters that could go p and between s. Here is an example that may help:

    SQL> WITH student AS
      2  (
      3          SELECT 'raj' AS first_name FROM dual UNION ALL
      4          SELECT 'kris' AS first_name FROM dual UNION ALL
      5          SELECT 'tanvi' AS first_name FROM dual UNION ALL
      6          SELECT 'shweta' AS first_name FROM dual UNION ALL
      7          SELECT 'rajendra' AS first_name FROM dual UNION ALL
      8          SELECT 'kapil' AS first_name FROM dual UNION ALL
      9          SELECT 'vipin' AS first_name FROM dual UNION ALL
     10          SELECT 'sandeep' AS first_name FROM dual
     11  )
     12  SELECT first_name
     13  FROM   student
     14  WHERE  REGEXP_LIKE(first_name,'^s.*p$')
     15  ;
    
    FIRST_NA
    --------
    sandeep
    
  • Help me with strings of small groups to interpolate the symbols in REGEXP_LIKE

    If I have this PL/SQL that works very well for me and I had to add another condition, which is a REGEXP_LIKE... and I heard that

    PL/SQL has a problem with special symbols and I need to get out them by interpolating, here is the line I added and I do not know how...

    or REGEXP_LIKE (ADDR_DELVRY, "[a-zA-Z0-9._%-]+@[a-zA-Z0-9._%-]+\. [a-zA-Z] {2,4} ")"

    Thank you!

    Hello

    Kodiak_Seattle wrote:

    If this string:

    or REGEXP_LIKE (ADDR_DELVRY, "[a-zA-Z0-9._%-]+@[a-zA-Z0-9._%-]+\. [a-zA-Z] {2,4} ")"

    in SQL is fine, but when I put it in a PL/SQL it generates errors and I was told that it is because of special characters that must be broken out...

    Here is everything:

    SQL_STMT_C_1 varchar2 (2000): = ' create table Y775. TABLE_TEST COMPRESS as

    Select / * + parallel (AUTO) * / a.cust_skey, a.name_first, a.name_last, a.ADDR_DELVRY, a.ADDR_DELVRY2,.

    a.ADDR_CITY_NAME, a.ADDR_STATE_NAME, a.ADDR_POSTAL_CODE, b.MKT_MAIL_PREF_IND

    from Table_A a, Table_B b

    where a.cust_skey = b.cust_skey

    and (a.A_SURV_DT > = 20101028 and b.MAIL_IND ("y", "U"))

    and (instr (upper (a.ADDR_DELVRY), 'XX') > 0 OR instr (upper (a.ADDR_DELVRY2), 'XX') > 0 OR instr (upper (a.addr_city_name), 'XX') > 0)'

    or REGEXP_LIKE (ADDR_DELVRY, "[a-zA-Z0-9._%-]+@[a-zA-Z0-9._%-]+\. [a-zA-Z] {2,4} "))';

    Is this really all that?  Are you sure there are no (for example) of a DECLARE statement before that?

    The last line you posted above is supposed to be part of the literal string assigned to sal_stmt_c_1?  If so, not the literal en at the end of the line before cela.

    Remember, if you want to have a single quote inside a string literal, then you must use single quotes in a row 2.  You did correctly before the last line, for example, when you said:

    ... and (a.A_SURV_DT > = 20101028 and b.MAIL_IND IN (""Y"", """U", "")...)

    Do the same sort of thing in the last line (or use Q-rating to the string literal). See the manual of the SQL language

    http://docs.Oracle.com/CD/E11882_01/server.112/e26088/sql_elements003.htm#sthref347

  • Oracle 10 g 2: hanging of session after "select regexp_like.

    Hello

    We use an Oracle database 10 g 2 (10.2.0.5.0) installed on a Windows Server 2003 (x 64).

    Yesterday a simple query (select * from table where regexp_like (upper (filename), ' ^ [aA - zZ] {0,1} * $')) has been started but never came back. Any other question on the same table

    runs without any problem. Trying to kill the session with "alter system kill session...". "the session has maintained the State of being killed (currently for over 24 hrs.).

    Seems quite odd to me since Oracle has no need to restore anything - ist was just the select which was performed at this session. The fort of event wait this session

    is "SQL * Net message from client. However rebooting the computer Client did not help either. The database seems to be in good shape - at least that does not session

    nothing, don't. Rebound of the database is not possible - but certainly will solve this problem.

    Any ideas or maybe a bug known?

    Rgds

    J.

    Good question, system administrator Ask, they should have a windows administration tool (I don't know the name) which will allow them to find all threads of a process Oracle.exe.

    I had a similar problem and windows administrator was able to follow this thread and kill for me.

    Pradeep

  • REGEXP_LIKE to match a phrase (other than the signs of punctuation and space.)

    Hello

    l_text1 VARCHAR2 (2500): = ' a great phrase that has, my phrase not found; And also other text ';

    l_text2 VARCHAR2 (2500): = ' a great phrase that has, my - phrase not found; And also other text ';

    l_search_string VARCHAR2 (2500): = ' (^ | \s|) [[: punct :]])]] My (\s+) sentence (\s+) nice (\s+) (\s+) found([[:punct:]]|\s|$)';

    REGEXP_LIKE (Upper (l_text1), l_search_string) returns true

    REGEXP_LIKE (Upper (l_text2), l_search_string) returns false.

    Help on the search string so that it is found in text1 and text2.

    Kind regards

    Ngandu

    Hi, Thierry.

    Here's one way:

    SELECT str

    FROM table_x

    WHERE REGEXP_LIKE (str

    , '(^| ([[: punct:] [: space:]]) MY'       ||

    "[[: punct:] [: space:]] + SENTENCE ' |"

    "[[: punct:] [: space:]] + to ' |"

    "[[: punct:] [: space:]] + BE' |"

    "[[: punct:] [: space:]] + FOUND' |"

    "([[: punct:][:space:]]|$)'"

    , 'i'

    )

    ;

  • REGEXP_LIKE for more of a range of numbers.

    Hi all.


    It is a pleasure to receive your help.

    I use Oracle Database 10 g Enterprise Edition Release 10.2.0

    I want to leave a string of pairs of numbers (where each pair represents a range) to know if my setting number is between pairs.

    Something like the following.

    SQL:

    declare
      i     pls_integer := 0;
      s     varchar2(100) := '^([74010000-74019999]|[85990000-85990999])';
      test1 varchar2(8) := '64010000';
      test2 varchar2(8) := '74010000';
    begin
      begin
        select 1 into i from dual where regexp_like(test1, s);
        dbms_output.put_line(i);
      exception
        when no_data_found then
          dbms_output.put_line(0);
      end;
      begin
        select 1 into i from dual where regexp_like(test2, s);
        dbms_output.put_line(i);
      exception
        when no_data_found then
          dbms_output.put_line(0);
      end;
    end;
    
    
    

    With the expected result below.

    Output (It didn't happen):

    0
    1
    

    Actual output:

    1
    1
    

    Suggestions?

    I'm looking for the literal correct.

    I thank in advance

    Filippe

    No prob

    drop table test

    CREATE TABLE test

    (NUMBER n

    );

    INSERT INTO test (n) VALUES (64010000);

    INSERT INTO test (n) VALUES (74010000);

    with input_data as)

    Select regexp_substr (t.val, "[^;]") +', 1, level * 2-1) to_search, regexp_substr (t.val, "[^;]") +', 1, level * 2) end_num

    (Select '74010000; 74019999; 84010000; 84019999; 94010000; 94019999' VAL double) t

    connect regexp_substr (t.val, "[^;]") +', 1, level * 2) IS NOT NULL

    )

    Select

    *

    of input_data, test

    where

    n between to_search and end_num

    TO_SEARCH END_NUM N

    74010000 74019999 74010000

    Just to get the whole picture

    with input_data as)

    Select regexp_substr (t.val, "[^;]") +', 1, level * 2-1) to_search, regexp_substr (t.val, "[^;]") +', 1, level * 2) end_num

    (Select '74010000; 74019999; 84010000; 84019999; 94010000; 94019999' VAL double) t

    connect regexp_substr (t.val, "[^;]") +', 1, level * 2) IS NOT NULL

    )

    Select

    *

    Of

    input_data

    full outer join

    test

    on

    n between to_search and end_num

    TO_SEARCH END_NUM N

    74010000 74019999 74010000

    84010000 84019999-

    94010000 94019999-

    -6401000

    chris227: the entire image added

    be complete it shoul be "n between to_number (start_num) and to_number (end_num)" accuracy

  • Regexp_like with check constraint

    Hi all

    My requirement is user does not enter data such as (½, ¼,...).
    I created the table with the constraint validation with the following syntax:


    CREATE TABLE mytest (c1 VARCHAR2 (20),)
    CHECK (REGEXP_LIKE(c1,'^[[:alnum:]+[:digit:]+[!@#]]+$')));)

    The means above, except alphanumeric, should enable figures and characters from the keyboard. But it does not have any character.

    Please help me, any error in the syntax above.

    Thank you
    Mano

    Alnum already includes numbers well, you don't need to Pack! @# in [] within []:

    SQL> CREATE TABLE mytest (c1 VARCHAR2(20),
      2  CHECK (REGEXP_LIKE(c1,'^[[:alnum:]!@#]+$')));
    
    Table created.
    
    SQL> insert
      2    into mytest
      3    values('@xyz1abc')
      4  /
    
    1 row created.
    
    SQL> insert
      2    into mytest
      3    values('@xyz1abc*')
      4  /
    insert
    *
    ERROR at line 1:
    ORA-02290: check constraint (SCOTT.SYS_C0019122) violated
    
    SQL>  
    

    SY.

  • REGEXP_LIKE Condition

    Dear all,

    I would use the condition REGEXP_LIKE expression with "[: alnum:]' operator in Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 to check the string alphanumeric or not."
    Why do I need: I have xinput field [RAW (24)] is not sure to always contains an alphanumeric string. We should use it only when the xinput field is an alphanumeric string.

    x varchar2 (50);
    x:=RTrim(LTrim(utl_raw.cast_to_varchar2(XInput)));

    Please help me how can I use REGEXP_LIKE or if you have a better suggestion please let us know?
    Thank you very much!

    Select "TRUE" where double REGEXP_LIKE ('True', ' [: alnum :]')])

    Select "TRUE" where double REGEXP_LIKE ('False%*^tt123.***', ' [: alnum :]')])

    Best regards
    Laszlo

    Or you can also use

    REGEXP_COUNT with laureline Solution

    where regexp_count(col, '[[:punct:]]+') = 0;
    
  • As the syntax need help

    I need code that starts with 't', '3', 'U', but the code below does not work. Can someone help me with the correct syntax.

    code like ('T%','3%','U%')
    Published by: varun on May 4, 2012 15:32

    Hello

    Varun says:
    I need code that starts with 't', '3', 'U', but the code below does not work. Can someone help me with the correct syntax.

    code like ('T%','3%','U%')
    

    Sorry, you can not do this. LIKE takes exactly 2 operands. Neither one can be a list, and you cannot use ALL, ALL or OPERATORS with LIKE.

    If you don't want to write 3 conditions, connected by OR, then look for something more LIKE to get the desired results.

    In this example, you are only interested in the 1st character. SUBSTR is an easy way to get the first character, so you can say

    SUBSTR (code, 1, 1)   IN ('T', '3', 'U')
    

    which is how I would prefer to do this particular task, although AS worked as you tried.

    Otherwise, try regular expressions, you can consider SIMILAR on steroids:

    REGEXP_LIKE ( code
                , '^(T|3|U)'
                )
    

    I hope that answers your question.
    If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.
    Explain, using specific examples, how you get these results from these data.
    Always tell what version of Oracle you are using.
    See the FAQ forum {message identifier: = 9360002}

    Published by: Frank Kulash, may 4, 2012 18:38

  • Need help with instr/Regexp for the query

    Hi people of Oracle

    I use Oracle

    Oracle Database 11 g Enterprise Edition Release 11.1.0.7.0 - 64 bit Production
    With partitioning, OLAP, Data Mining and Real Application Testing options

    I have a few responses from students and the valid values are + / / (alphabet) o/p and spaces at the end of the scam only not in the middle.

    According to my condition, the registration number 2 3.4 must be in the request but I'm alone (chart 3).

    Can we use REG_EXP

    Help, please.

    Thanks in advance.

    Rajesh

    with x as)
    (
    SELECT '+-+-POPPPPPP' STUDENT_RESPONSE, 1 numero_enregistrement FROM DUAL Union all the
    SELECT ' + --AOPPPPPP++' STUDENT_RESPONSE, 2 numero_enregistrement FROM DUAL Union all the
    SELECT "+-+-OPPPPPP -' STUDENT_RESPONSE, 3 numero_enregistrement FROM DUAL union all
    SELECT '+-+-9OPPPPPP' STUDENT_RESPONSE, 4 numero_enregistrement FROM DUAL)
    )
    (SELECT NUMERO_ENREGISTREMENT,
    TRIM (STUDENT_RESPONSE) X
    WHERE
    ((INSTR (UPPER (TRIM (STUDENT_RESPONSE)),'-') = 0))
    OR (INSTR (UPPER (TRIM (STUDENT_RESPONSE)), '+') = 0)
    OR (INSTR (UPPER (TRIM (STUDENT_RESPONSE)), 'O') = 0)
    OR (INSTR (UPPER (TRIM (STUDENT_RESPONSE)), 'P') = 0)
    OR (INSTR (UPPER (TRIM (STUDENT_RESPONSE)),' ')! = 0)
    )
    )

    Hi, Renon,

    Rb2000rb65 wrote:
    Hi people of Oracle

    I use Oracle

    Oracle Database 11 g Enterprise Edition Release 11.1.0.7.0 - 64 bit Production
    With partitioning, OLAP, Data Mining and Real Application Testing options

    Thanks for posting this (and the WITH clause for sample data). It is very useful.

    I have a few responses from students and the valid values are + / / (alphabet) o/p and spaces at the end of the scam only not in the middle.

    You combine several qeustions responses in a single VARCHAR2 column? It would be better to have a separate line for each question.

    According to my condition, the registration number 2 3.4 must be in the request but I'm alone (chart 3).

    What exactly are your needs? You try to find the rows where the student_response contains one of the forbidden characters, or if it contains a space anywhere, but at the end of the string?

    Can we use REG_EXP

    Yes, but it's pretty easy and probably more effective, do not use regular expressions in this case:
    Here's one way:

    SELECT     record_number
    ,     student_response
    FROM     x
    WHERE     TRANSLATE ( UPPER ( RTRIM (student_response, ' '))
                , 'X+-OP'
                , 'X'
                )     IS NOT NULL
    ;
    

    In other words, once you remove the spaces and all occurrences of '+', '-', 'o' or 'P', then the forbidden characters are left, and you want to select the line, if there is one of these.

    If you really, really want to use a regular expression:

    SELECT     record_number
    ,     student_response
    FROM     x
    WHERE     REGEXP_LIKE ( RTRIM (student_response)
                  , '[^-+OP]'          -- or '[^+OP-]', but not '[^+-OP]'.  Discuss amongst yourselves
                  , 'i'
                  )
    ;
    

    but, again, it will be probably slower than the first solution, using TRANSLATE.

    Published by: Frank Kulash, October 17, 2011 13:05

    Published by: Frank Kulash, October 17, 2011 13:41
    What follows is a bit simpler that TRANSLATE:

    SELECT     record_number
    ,     student_response
    FROM     x
    WHERE     RTRIM ( UPPER ( RTRIM (student_response, ' '))
               , '+-OP'
               )          IS NOT NULL
    ;
    

Maybe you are looking for

  • How do I factory restore my aspire 572p-4429 v5 with a lost admin password?

    I recently got my girlfriend a demonstration unit aspire v5. However, it has a top admin password, I contacted the store and they did not know the password. I looked online and have not been able to find something solid. I was told by pulling the cmo

  • Windows Update will always on a blank page

    Original title : No matter how I try to load my windows update page page still fails to load even though it says that I have updates available. Help The page is empty and said don't load, I tried the download fixit from microsoft but that no longer w

  • Context menu behavior

    Develop with the 4.2 version of the JDE I'm confused about how the system behaves with context menus: I have a class form that inherits from the screen, containing an ObjectList for which I have provided a makeContextMenu function. I expect makeConte

  • Site to site VPN connectivity

    Just set up VPN site-to site for ASA 5515 x and 5505. The tunnel is in place, but could not ping to the other site 5505 and vice versa. This is the condition of the tunnel and ASA configs. Any help or comment is appreciated. Thank you! ASA5515X # sh

  • The cost to publish an application, an e-book

    HelloAs my subject clearly shows how to publish an eBook on iOS / Android / Windows Mobile?Many greetingsMichel