Please help with regular expression

Hello

With the help of my previous answers of the detachment, Re: procedure to extract several substring of a string , I've updated the query. But I don't get the answer you want in all cases. Could you please help me? My query is based on the previous announcement. Any other way to do this?
I'd really appreciate it.
select 
       ltrim ( regexp_substr(txt, '\[(\w+)', 1, level), '[')      as id, /* id is number */
       ltrim ( regexp_substr(ltrim ( regexp_substr(txt, ':[^]]+', 1, level), ':'), '\w+-*\d*', 1, 1), ':')  as qid, /* Qid could be char/number/space any combination except ':' */
       ltrim ( regexp_substr(ltrim ( regexp_substr(txt, ':[^]]+', 1, level), ':'), '\w+', 1, 2), ':')      as num,
      to_date( ltrim ( regexp_substr(ltrim ( regexp_substr(txt, ':[^]]+', 1, level), ':'), '[^:]+', 1, 3), ':'),'MM/DD/YY')   as effdate
from  (
                        select  '[10946:M100:N:][10947:Q1222:N:][38198:PPP-2:N:][13935:PPP-6:N:][38244:QQQ-4:Y:01/01/10]'     as txt
                        from     dual
         )
        connect by level <= length(regexp_replace(txt, '[^[]'));
I should get:
ID             QID          NUM         EFFDATE
10946     M100     N     
10947     Q1222     N     
38198     PPP-2     N     
13935     PPP-6     N     
38244     QQQ-4     Y     01-JAN-10
But, be
ID             QID          NUM          EFFDATE
10946     M100     N     
10947     Q1222     N     
38198     PPP-2     2     
13935     PPP-6     6     
38244     QQQ-4     4     01-JAN-10
Thank you

Hello

If the column number is wrong, isn't it?
Describe what should be the num column. For example "num is the 3rd part of :-delimited list placed in square brackets.

If this is what you want, and then change the definition of number of

...                     ltrim ( regexp_substr(ltrim ( regexp_substr(txt, ':[^]]+', 1, level), ':'), '\w+', 1, 2), ':')      as num,

TO

...                      REGEXP_SUBSTR  ( REGEXP_SUBSTR ( txt
                                      , '[^]]+'
                                            , 1
                                   , LEVEL
                                   )
                         , '[^:]+'
                         , 1
                         , 3
                         )       AS num,

Tags: Database

Similar Questions

  • Need help with regular expressions

    Hi all

    I need your help, because I have no ideas more...

    I have the following problem: in the column of the database table, I have the string with the names of files already uploaded to the database. For example: + File1_V01.txt +, + File1_v02.txt +, + File1_01_v01.txt +, etc. The string _vxx * + or _Vxx * + (non-case sensitive) represents the version of the file.

    Now the problem: I'll upload the file with the name + File1_v02.txt + (already exists in the table).
    If the file name already exists in the table the pl/sql function should get the name of the file with the following version number. In my case it takes + File1_v03.txt +.

    Is it possible to do this using SELECT with regular expressions?

    Best regards and thanks!
    with t as (
      select 'File_V05.txt' fn from dual union all
      select 'File_V04.txt' fn from dual union all
      select 'File2_v03.doc' fn from dual union all
      select 'File2_v115.doc' fn from dual union all
      select 'File2_v15.doc' fn from dual union all
      select 'File1_v03.doc' fn from dual union all
      select 'File1_v115.doc' fn from dual union all
      select 'File1_v999.doc' fn from dual union all
      select 'File2.doc' fn from dual union all
      select 'File2_v05.doc' fn from dual union all
      select 'File1_v01.txt' fn from dual union all
      select 'File1_v02.txt' fn from dual union all
      select 'File1_v1.txt' fn from dual union all
      select 'File1_v1.doc' fn from dual union all
      select 'File1_v2.txt' fn from dual union all
      select 'File2_v01.doc' fn from dual union all
      select 'File2_v02.doc' fn from dual union all
      select 'File1_ABC_v01_DEF.docx' fn from dual union all
      select 'File1_ABC_V02_ABC.docx' fn from dual union all
      select 'File1_ABC_v01_12_04_17.docx' fn from dual union all
      select 'ABC_V1_QWERT.pdf' fn from dual
    )
    
    select fn,
    case when fn!=fn_new then
     last_value(fn_new)
     over(partition by regexp_replace(upper(fn),'V[[:digit:]]+','') --(.*?V0*)([1-9]+)(\..*?)$
     order by nv
     rows between unbounded preceding and unbounded following
     )
    else fn
    end fn_new
    from (
        select
        case when v-1 <= 0 then fn
        else
               regexp_replace (fn,
                        '(_v|_V)(\d*)',
                        case
                        when length(substr(fn,v+1,p-v-1)+1) > (p-v-1)
                        then '\1'||to_char(substr(fn,v+1,p-v-1)+1)
                        else '\1'||lpad(substr(fn,v+1,p-v-1)+1,p- v-1,0)
                        end
               )
        end fn_new
        ,fn
        ,case when v-1 <= 0 then -1
         else
            substr(fn,v+1,p- v-1)+1
         end nv
        from (
            select fn, regexp_instr(upper(fn),'_V[[:digit:]]+',1,1,1) p, instr(upper(fn),'_V')+1 v from t
        )
    )
    order by fn
    
    FN     FN_NEW
    ABC_V1_QWERT.pdf     ABC_V2_QWERT.pdf
    File_V04.txt     File_V06.txt
    File_V05.txt     File_V06.txt
    File1_ABC_v01_DEF.docx     File1_ABC_v02_DEF.docx
    File1_ABC_v01_12_04_17.docx     File1_ABC_v02_12_04_17.docx
    File1_ABC_V02_ABC.docx     File1_ABC_V03_ABC.docx
    File1_v01.txt     File1_v3.txt
    File1_v02.txt     File1_v3.txt
    File1_v03.doc     File1_v1000.doc
    File1_v1.doc     File1_v1000.doc
    File1_v1.txt     File1_v3.txt
    File1_v115.doc     File1_v1000.doc
    File1_v2.txt     File1_v3.txt
    File1_v999.doc     File1_v1000.doc
    File2.doc     File2.doc
    File2_v01.doc     File2_v116.doc
    File2_v02.doc     File2_v116.doc
    File2_v03.doc     File2_v116.doc
    File2_v05.doc     File2_v116.doc
    File2_v115.doc     File2_v116.doc
    File2_v15.doc     File2_v116.doc
    
  • HELP WITH REGULAR EXPRESSIONS

    Hello
    I'm just experimenting with regular expressions

    My information in table are as shown below
    TABLE NAME: -  EMP_TEST
    
    STRUCTURE WITH DATA
    
      X_NAME
    ---------------------
    12456com
    ab1245com
    AXM4554.com
    Now, I pulled the following query to find the rows that have 1
    select *
    from emp_test
    where regexp_like (x_name,'[1]')
    
    RESULT AS EXPECTED : -
    
    
      X_NAME
    ---------------------
    12456com
    ab1245com
    Now, I want to do a query that will give me tose lines that do not have 1

    Initially I have run the following query
    select *
    from emp_test
    where regexp_like (x_name,'[^1]')
    
    RESULT NOT AS EXPECTED : -
    
      X_NAME
    ---------------------
    12456com
    ab1245com
    AXM4554.com
    After a bit of searching on Google I found an application that works as expectd
    select *
    from emp_test
    where regexp_like (x_name,'^[^1]*$')
    
    RESULT AS EXPECTED : -
    
      X_NAME
    ---------------------
    AXM4554.com
    Where my basic question is that all seeking a 1 in a row we do not put the beginning ^ end $ and so on and the
    Works of query.
    So why do [^ 1] does not work as shown, while excluding an amd why is ^ [^ 1] * $ necessary while excluding a

    Hello

    Elessar wrote:
    So why do [^ 1] does not work as described

    Because regexp_like(str,'[^1]') means: search str who have at least one character that is not 1.
    When regexp_like(str,'^[^1]*$') means: search str done characters that are not 1 start (^) at the end ($)

  • Need help with regular Expression (RegEx)

    Try to wrap your head around a regular Expression for the following format example: 0022-C-4452 OR 0022-C-4452-C


    * The 4 digits are always numbers

    * The last 5 digits are alpha numeric

    * Last (if used) digit is always 'C' (in reference to the second structure)

    Hold the dashes for "auto fill" if possible? This would be in the Custom Format? Sequence of keys? Or Validation? I appreciate any help!

    I still think that you did not correctly describe your problem.

    1 figures of 4 characters.

    Optional separator.

    Then 6 alphanumeric characters and ' - '.

    OR

    1 figures of 4 characters.

    Optional separator.

    Then 6 alphanumeric characters and ' - '.

    Optional separator.

    Character 'C '.

    Note that the "-" is not a number and not an alphabetic character. It is a white space character.

    Try:

    function {MyRe (cString)
    var cFormatted = "";
    var RE_MyCode0 = /^(\d{4})[-.]) {0,1} ([A-Za-a0 - 9-] {6}) $/;
    var RE_MyCode1 = /^(\d{4})[-.]) {0,1} ([A-Za-a0 - 9-] {6}) [-.] {0,1} ([C]) $/;
    If (RE_MyCode0.test (CString) == true) {}
    cFormatted = RegExp. $1 + '-' + RegExp. $2;
    }
    If (RE_MyCode1.test (CString) == true) {}
    cFormatted = RegExp. $1 + '-' + RegExp. $2 + '-' + RegExp. $3;
    }
    Return cFormatted;
    } / / end of MyRe function;

    some tests;
    var MyString = "0022-C-4452; good channel;
    Console.println ("Input:" + MyString);
    Console.println ("result:" + MyRe (MyString));

    var MyString = "0022-C-4452-C; string of Goo;
    Console.println ("Input:" + MyString);
    Console.println ("result:" + MyRe (MyString));

    var MyString = "A022-C-4452" / / bad string;
    Console.println ("Input:" + MyString);
    Console.println ("result:" + MyRe (MyString));

    var MyString = '0022-4452-CZ' / / bad string;
    Console.println ("Input:" + MyString);
    Console.println ("result:" + MyRe (MyString));

  • Need help with regular expression

    I have a string like: separation by a comma as G, H, L

    the table has values like this

    Col1 Col2
    ROW1 G
    ROW2 F
    ROW3 L

    What is trying to achieve is to find out if G or H or L in the string of separated by commas are in col2. is it possible by using regular expressions or not we do split and the loops?

    Thanks in advance.

    Hello

    ora1001 wrote:
    I have a string like: separation by a comma as G, H, L

    the table has values like this

    Col1 Col2
    ROW1 G
    ROW2 F
    ROW3 L

    What is trying to achieve is to find out if G or H or L in the string of separated by commas are in col2. is it possible by using regular expressions or not we do split and the loops?

    Thanks in advance.

    You don't even need regular expressions

    INSTR ( ',' || col1 || ','
          , ',' || col2 || ','
          )
    

    will be greater than 0 if (and only if) co12 is one of the elements of col1.

    If you're curious, a way of using regular expressions is

    REGEXP_LIKE ( col1
             , '(^|,)' || col_2 || '($|,)'
             )
    

    but it will be less effective than Instr.

    Published by: Frank Kulash, November 5, 2010 11:38

  • Please help with download. ?

    Please help with the download?

    Available downloadable Setup files:

    Download and installation help links Adobe

    Help download and installation to Prodesigntools links can be found on the most linked pages.  They are essential; especially steps 1, 2 and 3.  If you click on a link that does not have these listed steps, open a second window by using the link to Lightroom 3 to see these "important Instructions".

  • Get error 207 trying to download creative Cloud and someone please help with this problem, thanks in advance please.

    Get error 207 trying to download creative Cloud and someone please help with this problem, thanks in advance please.

    Please refer to

    Error 207 to "install Adobe".

  • I need to reactivate Photoshop CS4 because I have a new hard drive in a reminder for my 2.5 yr old iMac last operating system running. When you open the program, I was told to contact Adobe support and give them an error code: 150:30. Please help with per

    I need to reactivate Photoshop CS4 because I have a new hard drive in a reminder for my 2.5 yr old iMac last operating system running. When you open the program, I was told to contact Adobe support and give them an error code: 150:30. Please help with permission. ?

    You can repair it yourself. I have a screenshot guide. You use app the Mac Terminal and a python (.py) script that comes with the recovery of the license for the Mac package.

    Don't forget to leave a space after typing sudo python and note that your password will not display any points. Simply enter it blind.

    Start 11 Message and take your time. It does not work. Layout error 150:30 opening Photoshop cs4 on Macbook Pro

    Gene

  • Mask a number with regular expressions

    Hi @ll!

    Is it possible to hide a given number

    of "12345678" in "XXXX5678".
    or '987458' to 'XX7458 '.

    with Regular Expressions and without substr()? To display only the last four digits and the 'X' value for the rest. The size of the number is not always the same.

    Alex, I think the OP wanted the first 4 characters to hide ;)

    Something like that?

    select translate(substr('12345678',1,length('12345678')-4),'1234567890','XXXXXXXXXX')
                    || substr('12345678',length('12345678')-3)
              from dual
    /
    TRANSLAT
    --------
    XXXX5678
    

    More

    with test_data as
    (
    select '12345678' card_no from dual
    union all select '123456' from dual
    union all select '5678900' from dual
    ) -- End of test data
    select translate(substr(card_no,1,length(card_no)-4),'1234567890','XXXXXXXXXX') ||
              substr(card_no,length(card_no)-3)
        from test_data
    /
    
    TRANSLATE(SUBSTR
    ----------------
    XXXX5678
    XX3456
    XXX8900
    

    Arun-

  • Problem with regular Expression

    Hello!!
    I have a problem with the regular expression. I want to validate only one word, and second are the same. To do this, I wrote a regex

    Model p=Pattern.compile("([a-z][a-zA-Z]*)\\s\1");
    Matcher m = p.matcher ("nikhil nikhil");
    Boolean t = m.matches ();
    If (t)
    System.out.println ("it's a game");
    on the other
    System.out.println ("is no match);

    The result I get is always 'there no match. "

    Your timely help will be very appreciated.

    Concerning

    Hello.

    You are missing a slash in the regex

    Pattern p = Pattern.compile("([a-z][a-zA-Z]*)\\s\\1");
    Matcher m = p.matcher("nikhil nikhil");
    boolean t = m.matches();
    if (t) {
        System.out.println("There is a match");
    } else {
        System.out.println("There is no match");
    }
    
  • HP Pavilion P7-1110: Please help with editing after scanning

    I know how to analyze an element, but after that I scan I do not know how to edit. I have Micro Soft Word 10 and my scanner is a HP Officejet 4630. If you can please help and thank you.

    Hi Tadpolegreen,

    Thank you for answering my questions!

    I would recommend going by there how to scan guide Scan in Windows 7 with full functionality software HP for HP Multifunction printers. Select how to scan with the HP software and how to scan in the form of editable text (OCR), follow the instructions.

    I hope this helps!

  • Please help with my reader prs 505

    Hi thr,.

    Please help me on my prs 505 reader, the display got very light canoe even read the words correctly, what's wrong with it, please help

    Thank you

    Jeevani

    Hi Jeevani,

    Welcome to the community of Sony!

    Sony Electronics apologizes for any question, you have met with your product. A small number of E Ink devices, with specific display panels, can become sensitive to the discoloration of the display when a page is turned while watching in strong direct sunlight. Clear the display is only temporary and can be corrected by adjusting the angle of the camera to avoid direct light from the Sun and then a page turns.

    Also, try the steps on the below technical support article:

    http://www.KB.Sony.com/selfservice/documentLink.do?externalId=C1008817

    Thank you for your message.

  • Please help with if, then formula

    I'm having troble with so and so, please help. So here's my question, if E is less than or equal to 30, then multiply K by 12% and specify the amount of 12% at Mr. Merci for your help and please show me the formula.

    Do you mean something like this?

    The formula in the column N:

    = IF(E≤30,K*12%,"")

    You do not specify what you want if the value of E is > 30, so the formula here is nothing.  If you want something, then replace ' ' to the desired value.

    SG

  • Very slow Macbook Pro (2012), please help with report EtreCheck

    Hi all

    My Macbook runs very slowly, I tried a number of things suggested online but none worked. I recently went to a repair shop and they suggested it could be to do with the dataflex (not sure if this was exactly, but I remember it sounding similar.) They described as a hard drive to another internal component connection, sorry for the inaccuracy.) I have me am replaced, but this did not help either.

    I downloaded the software EtreCheck and I was wondering if someone could help me to make light of the report on possible solutions? I have the feeling that it could be the hard drive needs to be replaced, but have no evidence of that. Verification has been run for the problem of "Beachballing" and got the sub report, please let me know if more info would be helpful. I hope it's telling in a way!

    Thank you for the pointers.

    EtreCheck version: 2.7.8 (238)

    Report generated 2016-01-26 22:56:56

    Download EtreCheck from http://etrecheck.com

    Duration 10:23

    Performance: Poor

    Click the [Support] links to help with non-Apple products.

    Click [details] for more information on this line.

    Problem: Beachballing

    Hardware Information:

    MacBook Pro (13-inch, mid-2012)

    [Data sheet] - [User Guide] - [Warranty & Service]

    MacBook Pro - model: MacBookPro9, 2

    1 2.5 GHz Intel Core i5 CPU: 2 strands

    4 GB of RAM expandable - [Instructions]

    BANK 0/DIMM0

    OK 2 GB DDR3 1600 MHz

    BANK 1/DIMM0

    OK 2 GB DDR3 1600 MHz

    Bluetooth: Good - transfer/Airdrop2 taken in charge

    Wireless: en1: 802.11 a/b/g/n

    Battery: Health = Normal - Cycle count = 420 - SN = 9G22603YVD3MB

    Video information:

    Graphics Intel HD 4000

    Color LCD 1280 x 800

    Software:

    OS X Mavericks 10.9.5 (13F34) - since startup time: less than an hour

    Disc information:

    Disk0 APPLE drive HARD TOSHIBA MK5065GSXF: (500,11 GB) (rotation)

    EFI (disk0s1) : 210 MB

    Macintosh HD (disk0s2) /: 499,25 go-go (248,48 free)

    HD (disk0s3) [recovery] recovery: 650 MB

    OPTIARC DVD RW AD - 5970H)

    USB information:

    Apple Inc. FaceTime HD camera (built-in)

    Apple Inc. Apple keyboard / Trackpad

    Computer, Inc. Apple IR receiver.

    Apple Inc. BRCM20702 hub.

    Apple Inc. Bluetooth USB host controller.

    Lightning information:

    Apple Inc. Thunderbolt_bus.

    Guardian:

    Mac App Store and identified developers

    Launch system officers:

    [failure] com.apple.maspushagent.plist [details]

    Launch system demons:

    com.Apple.Security.syspolicy.plist [failure]

    Launch officers:

    [loading] com.google.keystone.agent.plist [Support]

    [loading] com.oracle.java.Java - Updater.plist [Support]

    Launch demons:

    [loading] com.adobe.fpsaud.plist [Support]

    [loading] com.google.keystone.daemon.plist [Support]

    [loading] com.oracle.java.Helper - Tool.plist [Support]

    Items in user login:

    iTunesHelper Application (/ Applications/iTunes.app/Contents/MacOS/iTunesHelper.app)

    Other applications:

    [ongoing] com.etresoft.EtreCheck.85920

    Plug-ins Internet:

    FlashPlayer - 10.6: Version: 19.0.0.226 - SDK 10.6 [Support]

    QuickTime Plugin: Version: 7.7.3

    Flash Player: Version: 19.0.0.226 - SDK 10.6 obsolete! Update

    Default browser: Version: 537 - SDK 10.9

    o1dbrowserplugin: Version: 5.41.0.0 - SDK 10.8 [Support]

    googletalkbrowserplugin: Version: 5.41.0.0 - SDK 10.8 [Support]

    JavaAppletPlugin: Version: 25 check the version of Java 8 update

    3rd party preference panes:

    Flash Player [Support]

    Java [Support]

    TeXDistPrefPane [Support]

    Time Machine:

    Time Machine not configured!

    Top of page process CPU:

    6% update_dyld_shared_cache

    4% WindowServer

    3% kernel_task

    mdworker (3) 2%

    1% launchd (4)

    Top of page process of memory:

    508 MB com.apple.WebKit.WebContent (4)

    502 MB kernel_task

    Safari of 283 MB

    Finder 197 MB

    152 MB softwareupdated

    Virtual memory information:

    988 MB of free RAM

    3.03 GB used RAM (750 MB cache)

    Used Swap 0 B

    Diagnostic information:

    26 January 2016, 21:59:30 self-test - spent

    Hello mrdivorce,

    It looks like of course as evidence of a hard drive failing for me. Hard drives 2.5 "in the MacBook Pro tend to fail after 2-3 years. Judging by the date on your MacBook, I think that your time is up. Maybe try to find a different repair store. Looking for Service Center authorized Apple (https://locate.apple.com/).

    I suggest upgrading to an SSD and increasing your RAM too. Then you have the hardware to run the last OS X 10.11.

  • have dell dimension 4700 xp need help with outlook express I have error message and can not send email

    I need help to figure out why my outlook express does not work when I try to send a link, or email. I have a dell dimension 4700 xp restored. The error message cannot find the server with an error code number. I am a newbee so one who responds to it will have to break it down for me. So far, I had lots of help from proceeding to audio and graphics, and I am totally grateful for the help I get.

    Thank you, Gina Davis

    I have

    He has already worked with Outlook Express? Using OE? Hotmail is a Webmail service.

    How to add your Hotmail e-mail account to Microsoft Outlook Express
    http://windowslivehelp.com/solution.aspx?SolutionID=99d4b13d-13dB-40D8-9cdf-172002d4194c

    If you don't want to use OE to access Hotmail and want to just use IE to access Hotmail, then just copy the link and paste it into a new message from Hotmail.

Maybe you are looking for