regular exp

Hi all

I expect only "ABC" combination in the string if I have other that the combination of the CBA, I do this line with the null value

I use oracle 11.2 (Toad)

WITH t1
DID (1 SELECT ID, "ABCD" DOUBLE STR
UNION ALL
SELECT 2, 'ABC' OF THE DOUBLE
UNION ALL
SELECT 3, 'A' OF THE DOUBLE
UNION ALL
SELECT OPTION 4, 'B' OF THE DOUBLE
UNION ALL
SELECT 5, THE DOUBLE ' C'
UNION ALL
6 SELECT, HAD "DOUBLE
UNION ALL
SELECT 7, "AD" OF THE DOUBLE
UNION ALL
SELECT 8, 'AE' OF THE DOUBLE
UNION ALL
SELECT 9, "BC" OF THE DOUBLE
UNION ALL
SELECT 10, "AC" TO DOUBLE)
SELECT *.
FROM t1


EXPECTED

ID str

1
2 ABC
3A
4 B
5 C
6

7
8
9 BC.
10 AC

Thanks in advance

Hello

849776 wrote:

Hi all

I expect only "ABC" combination in the string if I have other that the combination of the CBA, I do this line with the null value

I use oracle 11.2 (Toad)

WITH t1
DID (1 SELECT ID, "ABCD" DOUBLE STR
UNION ALL
SELECT 2, 'ABC' OF THE DOUBLE
UNION ALL
SELECT 3, 'A' OF THE DOUBLE
UNION ALL
SELECT OPTION 4, 'B' OF THE DOUBLE
UNION ALL
SELECT 5, THE DOUBLE ' C'
UNION ALL
6 SELECT, HAD "DOUBLE
UNION ALL
SELECT 7, "AD" OF THE DOUBLE
UNION ALL
SELECT 8, 'AE' OF THE DOUBLE
UNION ALL
SELECT 9, "BC" OF THE DOUBLE
UNION ALL
SELECT 10, "AC" TO DOUBLE)
SELECT *.
FROM t1

EXPECTED

ID str

1
2 ABC
3A
4 B
5 C
D 6
7
8
9 BC.
10 AC

Thanks in advance

Why do you want to be ' id = 6?  Why not NULL?

Depending on your answer, you could get the desired results more effectively without regular expressions.  For example:

SELECT id

CASE

WHEN LTRIM (str, "ABC") IS NULL

THEN str

END as str

FROM t1

ORDER BY id

;

Tags: Database

Similar Questions

  • Reg: Regular Exp - help

    Hi Experts,

    I need help to use the regular Expression-

    WITH t AS)

    SELECT ' 1234 Angel Villa, House 420 | Detroit | WE | 700129' double txt

    )

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

    SELECT

    txt,

    SUBSTR (txt, InStr(txt,'||') + 2, (INSTR(txt,'|',1,3)-INSTR(txt,'||')-2)) val1,

    REGEXP_REPLACE (txt '([^ ||] *||) (.*)', '\2') val2

    T;

    I want to extract the text entry "Detroit" - going between the two. (begins - with that) and a. (ends - with that).

    txt - 1234 Angel Villa, House 420 | Detroit | WE | 700129

    val1 - Detroit

    val2 | Detroit | WE | 700129

    My regex is not appropriate somewhere. Please provide any suspicion in this regard (and not the exact solution - want to try)

    The backreference is very interesting but am very bad at writing regular expressions. Help much appreciated.

    Thank you and best regards,

    -Nordine

    (on Oracle 11.2.0.3.0 - Exadata)

    Published:

    Tried this now.

    REGEXP_REPLACE (txt '([^ ||] *||) ([^|] *) (|. *)', '\2') val2

    Output-

    ||||

    Nordine Hello B

    Yes, because you have more sign like | in this case you must use the non-greedy option for your star: *?

    I would use the REGEXP_SUBSTR.

    You must use the escape character \ and must be given to the * that you don't want to have the sign | Once again...

    It's a little hard to explain. If you want the solution tell me.

    Best regards, David

    P.S.: Because nobody didn't read you just wish that you do not want to have the right solution only just advice... And you already know the solution, so I post my solution too

    WITH t AS)

    SELECT ' 1234 Angel Villa, House 420 | Detroit | WE | 700129' double txt

    )

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

    SELECT

    txt,

    SUBSTR (txt, InStr(txt,'||') + 2, (INSTR(txt,'|',1,3)-INSTR(txt,'||')-2)) val1,

    REGEXP_REPLACE (txt '([^ ||] *||) (.*)', '\2') val2

    REGEXP_SUBSTR (txt '(\|) {2} ((.| ^(\|)) *?) (\|)', 1, 1, NULL, 2) LIKE REGEXP_RESULT --> Chris227 Correction

    T;

    Where:

    (Results): take this sign | but don't interpret as the OR operator.

    (\|) {2}: take the sign. twice

    .           : Take any character

    . *: Take among these characters, as you can

    .*?         : Take one of these characters, not the longest chain you will find (NON-greedy option:?)

    (.*?)       : Consider backreference in parentheses. REGEXP_SUBSTR last option is 2, because we want only the name of the city without sign.

    Last (-|)   : The name of the city must be accompanied by a sign.

    I hope it helps.

    The SQL above has been fixed-> reason: Chris227 noticed a mistake. Thanks Chris277!

  • Regular exp support

    Hello

    I want to search using regexp_like for field values that start with REC_AE or REC_

    Field of table values

    'REC_AE_TMPL_GEN '.

    'REC_TMPL_GEN '.

    I tried SELECT * FROM MODEL WHERE REGEXP_LIKE (category, ' ^ REC_(AE|??)) STAT ') but it does not work.

    Help, please

    Try this: ^ REC_ (AE_)? STAT

  • declare the variable

    I started warning after running this code.
    He says that this line variable has no type declaration.
    What should I do? This is the code-->

    I suggest you break it down and focus on the creation of the table of the lines before trying to move on as follows

    var myText:String = myText.text
    var myTextArr = myText.toString().split(/[\r\n]/g)
    trace (myTextArr.Length) / / should give you a count of all rows...

    / [\r\n]/g - is a regular exp that looks like for each newline character in the string that was created programmatically using \r to represent the newline

    You can also try variations of the rational expression until you get the number of rows, that you expect.

    / [\r\n]{1,2}/g - resembles a minimum of 1 and a maximum of 2 line breaks

    As a beginner, you have a hard work in front of you, I know it can get frustrating but trial and error is the search of google and way only for examples. Sample analysis weblogs out there he wrote too much already, a lot of developers is the willingness to help but little do not have the time to write the code for you. I recommend you read about regular Expressions too that they are an essential part of any directory of programmers

  • deletion of records with data from junk e-mail

    Hi all

    I have UNWANTED data in columns like. E¿¿¿.¿¿¿.@,nulls,special charecters,

    in delete statement wat should we indicate where clause?

    one you suggest no regular exp... to remove all data other than valid numbers or charectrs of a to Z...

    The problem then is white space, which will not be replaced. So just take the Karthick_Arp solution and add trim():

    length(trim(regexp_replace(col_name,'[[:alnum:]]',null))) > 0
    

    Published by: tk-7381344, November 18, 2008 07:48

  • A doubt on REG EXP

    Hi friends,

    Please specify the doubt in Reg Exp.

    Table EMP a sequel EMP_NAMEs:

    ============
    Anand
    Bala_G
    Chitra
    David_C
    Elango
    Faye
    ============

    We have a set of characters as "abcdefghijklmnopqrstuvwxyz0123456789".

    Now we must find EMP_NAMES County, whose characters (any) are not in the list of characters in the list above. In this example, the result should be 2. for example, "Bala_D" and "David_C. The query should be like:

    Declare
    v_string varchar2 (50): = "abcdefghijklmnopqrstuvwxyz0123456789";
    v_count number (6);
    Begin
    Select count (*)
    in v_count
    WCP
    where regexp_like (emp_name, v_string);

    dbms_output.put_line (v_count);

    end;

    ========================

    Thanks in advance!

    Hello

    Welcome to the forum!

    To use REGEXP_LIKE, you could say:

    WHERE     REGEXP_LIKE ( emp_name
                  , '[^abcdefghijklmnopqrstuvwxyz0123456789]'
                  )
    

    However, it will be faster not not to use regular expressions:

    WHERE   LTRIM ( emp_name
               , 'abcdefghijklmnopqrstuvwxyz0123456789'
               )          IS NOT NULL
    

    Published by: Frank Kulash on 10 October 2012 16:18
    Removed the extra single quote, after DAMorgan, below.

  • 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
    
  • One for the era: how to get this output using REGULAR EXPRESSIONS?

    How to get the bottom of output using REGULAR EXPRESSIONS?
    SQL> ed
    Wrote file afiedt.buf
    
      1* CREATE TABLE cus___addresses    (full_address                   VARCHAR2(200 BYTE))
    SQL> /
    
    Table created.
    
    SQL> PROMPT Address Format is: House #/Housename,  street,  City, Zip Code, COUNTRY
    House #/Housename,  street,  City, Zip Code, COUNTRY
    SQL> INSERT INTO cus___addresses VALUES('1, 3rd street, Lansing, MI 49001, USA');
    
    1 row created.
    
    SQL> INSERT INTO cus___addresses VALUES('3B, fifth street, Clinton, OK 74103, USA');
    
    1 row created.
    
    SQL> INSERT INTO cus___addresses VALUES('Rose Villa, Stanton Grove, Murray, TN 37183, USA');
    
    1 row created.
    
    SQL> SELECT * FROM cus___addresses;
    
    FULL_ADDRESS
    ----------------------------------------------------------------------------------------------------
    1, 3rd street, Lansing, MI 49001, USA
    3B, fifth street, Clinton, OK 74103, USA
    Rose Villa, Stanton Grove, Murray, TN 37183, USA
    
    SQL> The REG EXP query shouLd output the ZIP codes: i.e. 49001, 74103, 37183 in 3 rows.
    Published by: user12240205 on June 18, 2012 03:19
    /* Formatted on 2012/06/18 17:25 (Formatter Plus v4.8.8) */
    SELECT REGEXP_SUBSTR ((REGEXP_SUBSTR (full_address, '[^,]+', 1, 4)), '[[:digit:]]+') RESULT
      FROM cus___addresses
    
  • Regular expression to allow only numeric characters or spaces in the num field such

    Hi people

    Am Newbie Apex using 4.0.1 / Vista / Oracle XE and am trying to create a level validation element on a phone number field

    I want any combination of numbers and valid spaces with only the obvious condition that the field cannot be completely spaces.

    Can anyone help to suggest how to do because I'm really bad with something so simple that I have no exp prev reg expressions.

    Thank you, as always
    Peter

    Hello
    It's quite strange, I just tried your entry (without apostrophes) and it passed. Do you have you copied my reg exp (a ^ $ included) and pasted into the Expression of Validation 2 field validation with regular Expression of type? We must really work.

    Jirka

  • How exp a database of the user affected?

    I know that the system user and its password and there is another regular user, it's the name test, if I know it's password, I can exp test like the following:
    c:\ > exp test/testpw file=c:\\test.dmp

    but I don't know it's password. and I want to test user exp, how do?

    Thank you!

    exp system/pass@test owner = (test) = c:\ss file

  • slower than the utility exp expdp!

    Hello

    I need to compare utilities vs exp expdp and get hours for schemas in my application... I started today with a small diagram which is 1.5 GB. With the help of export utility that it took 3 minutes and 51 seconds to export it. but using expdp it takes 6 minutes and 16 seconds to make the export! Expdp is supposed to be faster, but in my case, I see the export do much better. Can anyone help to look into this.

    To export the I used after a command:

    log statistics exp_ = $1_$ 3.log exp $1 / $1 file = exp_$ $1_ 3.DMP = none direct owner = y = $1 for regular export
    and
    Directory of $1 / $1 = dir1 dumpfile = exp_ expdp $1_$ 3.DMP logfile = exp_$ $1_ 3.log = $1 patterns for data pump...

    I have passes three arguments and the second argument is schematic size small/big etc which, as well as the schema name is $1 and a number random i.e. $3 are used in the above commands.

    Can someone help me determine why the utility expdp is slower for my tests?


    Thank you
    Cedric

    Cedric,

    Usually his good idea set PARALLELS the number of CPU options, you have on the server. Because the largest number (number of CPUS) can also advarsely affect performance as well. Don't forget time CPU also dealt with by other procedures and processes more you spawan can serilaize their execution resulting in a decrease in performance. So from 2 or 4 will be a good idea.

    Concerning

  • the magic mouse disconnects regularly

    Since last week my Magic Mouse is losing connection with my iMac (OS X Sierra) pretty regularly--several times each hour, sometimes more often - the connection is only lost for 5-10 seconds, but it's a lot of time when you're trying to work. Anyone else had this problem and had been able to find a solution?

    If your Magic Mouse is version 1 (with batteries), it won't be to fully integrate with Sierra.   You can buy Magic Mouse 2 for that.   Because all future operating systems need, you may as well buy now.

  • In Keynote is regularly lost function undo

    Hello! I have a problem. In Keynote is regularly lost undo function. This happens randomly, and I don't understand why. Maybe it happens in some other iwork apps, but I have not tried yet used. He arrived in the Sierra of macOS. Аnyone have this happen?

    We have no problem with cancellations in any application on any of our Macs. I heard not only reports of one having this problem.

    Perform this procedure for Foundation repair;   Remove the application Keynote, empty the trash, restart the Mac and then re - install Keynote from the Mac App Store.

  • Regular and Nike + software.

    Anyone know if the software located on the Nike + (running program and features) series 2 can be downloaded and put on 2 regulare series watch?

    Hello

    The Nike + Run Club app can be installed on any Apple Watch.

    The Apple Watch Nike + includes a greater integration of the application as well as other features such as the Nike exclusive dial faces (in addition to the standard Apple Watch faces), and an exclusive group of Sport Nike.

  • My MacBook 12 regularly gets an analysis of needs of Unix executable file names in her basket

    My MacBook 12 regularly gets a Unix executable file named 'needsanalysis' in his trash. Anyone have any idea why? What is it? What can I do to stop what is happening?

    I have two laptops on a an environment MBA 2011 and a 2016 MB and it happens on the latter. Both are on OSX 10.11.6

    Thank you, Colin.

    The executable "unix" just means that it doesn't have an extension for the operating system is not what it is. In addition, the executable bits are defined, so it may have been a case, but this info was lost, too.

    Do you run all software anti-virus on them? I don't know what else would generate something that "needs analysis".

Maybe you are looking for