Extract numbers from a string

Hello
i'numbers in the neck of string arrecnote

Please help me in this...

Published by: smile on October 7, 2010 05:33

Published by: smile on October 7, 2010 06:14

Try this to extract the numbers from a string:

SQL> ed
Wrote file afiedt.buf

  1  with t as (select 'hello-cycle monthly settlement;  865.15 SDR
  2  
multilat net 218.15 (USD) USAWW-USACC-2007/10' col1 from dual) 3 SELECT * FROM 4 (SELECT REGEXP_SUBSTR(col1,'[0-9]+.[0-9]+',1,lvl) col1 FROM 5 (select col1,level lvl 6 from t 7 connect by level <= LENGTH(col1) - LENGTH(REPLACE(col1,' ')) + 1)) 8* WHERE col1 IS NOT NULL SQL> / COL1 -------------------------------------------------------------------------------- 865.15 218.15 2007/10 SQL> -- or if you just want the numbers with its decimal SQL> ed Wrote file afiedt.buf 1 with t as (select 'hello-cycle monthly settlement; 865.15 SDR 2
multilat net 218.15 124 (USD) USAWW-USACC-2007/10' col1 from dual) 3 SELECT * FROM 4 (SELECT REGEXP_SUBSTR(col1,'[0-9]+[.][0-9]+',1,lvl) col1 FROM 5 (select col1,level lvl 6 from t 7 connect by level <= LENGTH(col1) - LENGTH(REPLACE(col1,' ')) + 1)) 8* WHERE col1 IS NOT NULL SQL> / COL1 -------------------------------------------------------------------------------- 865.15 218.15 SQL>

Published by: AP on October 7, 2010 05:43

Tags: Database

Similar Questions

  • extract characters from a string

    Hi gurus,
    I want to extract the first, third, fifth, seventh... characters in a string.
    not to extract characters from a subset of characters in a select query in oracle 9i database.

    for example (1):
    Assume that a string like this "SUE" is that I am 'ACEGI"of the source string
    and the source can be any valid string, I just give an example here.

    Example (2) of "kalpataru' in klatau'

    Please guide me for this

    for 9i:

    SQL> with t as (
     select 'ABCDEFGHIJ' str from dual union
     select 'kalpataru' from dual
    )
    --
    --
     select str,
            trim(extract(xmlagg(xmlelement(e, substr(str,level,1)) order by level),'//text()')) str2   from t
      where mod(level,2) = 1
    connect by level <= length(str) and prior str = str and prior sys_guid() is not null
      group by str
    /
    STR        STR2
    ---------- --------------
    ABCDEFGHIJ ACEGI
    kalpataru  klaau         
    
  • regular expression - get the numbers from a string

    Hello world

    I'm trying to use regular expressions to get all the numbers in a string. The only problem is that the chain can vary.

    For example:

    It's my rope 3 and 8 I want 2 get out of those 7 numbers
    Random text 9 with 5 for everyone weekend 8

    How can I do?

    Thanks in advance :)

    Quote:
    Posted by: Scott Stroz

    #numbersOny #.

    Who will be only to crush all the numbers in a large number.

    The attached code will return a nice list of numbers.
    Though the numbers may contain commas or decimal points, the code can easily be adjusted

  • Extract text from a string

    How would extract everything before and after the LAST - (dash)?

    Example: mt-st-marys-fl...

    Everything preceding the latest scoreboard: mt-smarys

    Everything that follows the latest scoreboard: fl

    Before last dash: Replace(string, "-" & ListLast(string, "-"), "")
    After: ListLast(string, "-")
    

    Mack

  • How to get the numbers from a string?

    Hi all

    I have a string Let's say
    '0a1b2c3d4e5f '.

    I want to retrieve all the numbers out of it.

    012345

    Please Guide Me.

    Thank you

    Try

    SELECT REGEXP_REPLACE ('0a1b2c3d4e5f','(*[^[:digit:]]) ', ") double;

  • extract data from a string and compare it with sysdate

    Hello

    Since a few days I struggle to find a solution to my problem, maybe I have some luck here.

    Data type:

    11/23 ANA

    Alex 19/11

    1/11 tomorrow

    03/12 FW1

    Makes me tomorrow

    Bo 11/12

    Necessary data should be as MM/DD. I used substr and/or regexp_like, regexp_substr, but having a few problems.

    Months can be like 1, 2.11, 12 or 01,02, 03... 11, 12.

    I don't need the data in the format Month\Day.

    Basically all of the above "/" should be a month.

    And I need to get out all the foregoing, > 13.

    And I need to compare the exp with sysdate.

    Any ideas?

    THX

    something like:

    FUNCTION to CREATE or REPLACE makeDate (in_string in VARCHAR2
    in_format IN VARCHAR2: = ' MM/DD')
    date of return
    IS
    BEGIN
    To_date (in_string, in_format) return;
    exception
    When others then return null;
    end;
    /

    with sample_data as (choose 11/23 ANA' double str)
    Union of all the
    Select 19/11 Alex' double
    Union of all the
    Select 1/11 tomorrow "of the double
    Union of all the
    Select FW1 10/12 ' double
    Union of all the
    Select "Makes Me" tomorrow the double
    Union of all the
    Select ' Bo' 11/12 double
    UNION ALL
    SELECT 11/24 09:00 ' FROM dual
    )
    SELECT str
    OF sample_data
    WHERE REGEXP_LIKE (str, ' ^ [[: digit:]] {2} / [[: digit:]] {2}')
    and makeDate (regexp_substr (str, ' ^ [[: digit:]]{2}/[[:digit:]]{2}'))]]))<>

    /

    HTH

  • Extract words from a string

    Hello

    I need a SQL to meet the following requirements.

    Table

    Col1

    A AND B

    B C HAS

    Output

    Col1 Col2
    A B A

    A B B

    B C A B

    B C C

    C B A A

    I can do via PLSQL. But I need it in a SQL.

    Thank you

    Hello

    Here's one way:

    SELECT col1

    REGEXP_SUBSTR (col1,

    , '[^ ]+'

    1

    LEVEL

    ) AS col2

    FROM table_x

    CONNECT BY LEVEL<= regexp_count="" (="">

    , '[^ ]+'

    )

    AND PRIOR col1 = col1

    AND PRIOR SYS_GUID () IS NOT NULL

    ;

    Depending on your version, you may have to change the CONNECT BY clause.

  • selection of numbers from a string

    Hello
    I have a table with address information, and some records in my street_num area contains letters, e.g. (EN), (TO). Some of the records look like this...

    1___ (TO) 3874
    2___ (EN) 83
    3___3908 (TO)
    4___21 (EN)

    Is there a statement which will select only the numerical values so that I can fill out a new field with just the numbers?

    Thank you!

    Hello

    In Oracle 10 (and more), you can use regular expressions

    REGEXP_SUBSTR ( street_num
                  , '[0-9]+'
                  )
    

    Returns the first substring 1 or more digits of street_num.

  • By adding a '%' to the numbers from a string

    I have an expression that works in the animation of a percentage based on a slider control.

    n = thisComp.Layer ("null 1"). Effect ("the 2 pie slice") ("Slider")

    nRound = Math.round (n * 10) / 10;

    check = 1% nRound

    If (check == 0) {}

    "" + nRound + ".." 0"+ « % »

    } else {}

    nRound

    }

    What I can't understand, why is the '%' appears only when the number is full and not there permanently? After reading Dan Ebbert page, it shows that you can add in fact (which I thought I did it correctly) but only on integers. When he drives through the 'tenth' the % does not appear.

    I'm sure it's something simple, but I can't understand it.

    Thanks for your help.

    In your if/else statement you only add the % in cases where it is an integer. You will need to change to:

    If (check == 0) {}

    "" + nRound + ".." 0"+ « % » ;

    } else {}

    "' + nRound + '% ';

    }

    Also, here is another way to write the expression:

    n = thisComp.Layer ("null 1"). Effect ("the 2 pie slice") ("Slider");

    n.value.toFixed (1) + '% ';

  • How to extract the corresponding regex string

    Hello

    I am trying to extract text from a long string using QRegEx. Here's my regex:

    Rx QRegExp ("^. *(192|210). * key =? *");

    QString url = ""https://192.168.1.10/files/30/encrypt/key=s6h779bf " "

    rx.setPatternSyntax (QRegExp::Wildcard);

    rx.indexIn (str, 0);

    qDebug()<>

    qDebug()<>

    However, it is does not match anything.

    If I change the regular expression of "(192|210)." * key =? ' * ' can he match but I can't get the string after the = key

    You use a regular expression capture if you want that the parameter "key."

    QRegExp rx("^.*(192|210).*key=(.*)?");
    
    qDebug() << rx.cap(1);  // here's the first octet of your IP
    qDebug() << rx.cap(2);  // key parameter (optional)
    

    Your regex could do with a lot of improvement in my humble opinion. You might want to consuder the class QUrl that does what you want already:

    QUrl url("https://192.168.1.10/files/30/encrypt/key=s6h779bf");
    
    qDebug() << url.queryItemValue("key");
    

    Tip: rubular is a handy Tester on the regex web which makes this kind of thing much easier to debug

    http://rubular.com/

  • Extract information from the arrayCollection collection

    Hello world

    I have a very simple problem, but I'm a new flex developer and I have no idea what to do.

    that I extracted information from a database by using a Web service in coldfusion.

    in flex, I recovered my query result in an arrayCollection collection

    private var tabInfosDriver:ArrayCollection

    Private function driverInfoHandler(event:ResultEvent):Sub

    tabInfosDriver = event.result as ArrayCollection; collection

    and if I give {tabInfosDriver} as a dataprovider to a DataGrid, the result of the query is displayed correctly, something like that.

    Header1 By tete2 Header3 Header4 Header5
    someValuevalue2someValue3someValue4someValue5


    now, I want to use header1 someValue to fill a textField instance.

    I tried:

    Label1.text = tabInfosDriver.getItemAt (1.0) m:System.NET.SocketAddress.ToString)

    but it wrong: the index table out of range and in any case, I want to use the name of the header field, which is the database table to call its value

    Label1.text = tabInfosDriver.getItemAt("header1").value.toString)

    What can I do? I don't know that it is easy to solve. I looked at all the methods of the collection arrayCollection object, but I can't understand wich one to use.

    Please forgive me of my language, I do not speak English very often.

    Dominic

    Often you can either return the data to the Flex application in standard object notation, or to reconfigure the data in this way once he returns to the Flex application in the result handler. The standard notation, to which I am referring is:

    {

    {key1: 'value 1', key2: "Value2", key3: "Value3"},

    {key1: 'value 1', key2: "Value2", key3: "Value3"},

    {key1: 'value 1', key2: "Value2", key3: "Value3"},

    {key1: 'value 1', key2: "Value2", key3: "Value3"}

    }

    So in this way the data is structured, already as an associative array, because such a table is really just an ActionScript object.

    If these data should be accessible in two ways:

    var tempVar:String = myObject.key1;

    var tempVar:String = myObject ["key1"];    (maybe myObject ["key1"])

    Moreover, this "standard object notation" is also known under the name of JSON and there are libraries for handling JSON to the format of the data in Flex, PHP, etc if you have not necessarily to treat it as JSON, which comes, which makes it a little more formal and provides additional APIs:

    http://code.Google.com/p/AS3corelib/

  • Eliminating duplicates from a string

    Hello

    I would delete the duplicates of the coma-separated string using the pl/sql functions.
    How can I achieve this?

    Thank you

    You don't need a plsql

    with t as (select 'SCOTT,ALLEN,KING,SCOTT' as in_cls from dual)
    , t1 as ( select distinct regexp_substr(in_cls, '[^,]+', 1, rownum) names
                      from t
                      connect by rownum <= length(regexp_replace(in_cls, '[^,]'))+1)
    SELECT
        RTrim(xmlagg(xmlelement(a,names||',').extract('//text()')),',') string
    from t1
    /
    
    STRING
    ------------------------------------------------
    ALLEN,SCOTT,KING
    
    1 row selected.
    

    SS

  • Script Insert statement to extract data from Table in Oracle 7i

    Hi all, I have an old Oracle legacy system that works for more than 15 years. Every now and then, we need to extract data from this table @ ORacle 7i to import to Oracle 10 G.

    My thoughts are to create a script to Insert statements in oracle 7 and that, to be deployed to Oracle 10 G.

    I found cela scripts in Google and don't know exactly how it works. No explanation on these scripts, would be greatly appreciated. I find that this format can help to produce a set of insert statements in this table to the last table to 10G.

    < pre >
    -Step 1: create this procedure:
    create or replace function ExtractData (v_table_name varchar2) return varchar2 as
    Boolean b_found: = false;
    v_tempa varchar2 (8000);
    v_tempb varchar2 (8000);
    v_tempc VARCHAR2 (255);
    Start
    for tab_rec in (select table_name from user_tables where table_name = upper (v_table_name))
    loop
    b_found: = true;
    v_tempa: =' select ' insert into ' | tab_rec.table_name |' (';
    for col_rec in (select * from user_tab_columns)
    where
    table_name = tab_rec.table_name
    order by
    column_id)
    loop
    If col_rec.column_id = 1 then
    v_tempa: = v_tempa | " ' || Chr (10) | " ' ;
    on the other
    v_tempa: = v_tempa |', ". Chr (10) | " ' ;
    v_tempb: = v_tempb |', ". Chr (10) | " ' ;
    end if;
    v_tempa: = v_tempa | col_rec.column_name;
    If instr(col_rec.data_type,'CHAR') > 0 then
    v_tempc: = "' |' | col_rec.column_name |'| " ' ;
    elsif instr (col_rec.data_type, 'DATE') > 0 then
    v_tempc: = "' to_date ("'| to_char('|| col_rec.column_name||',''mm/DD/YYYY HH24 '') | ") (', "' dd/mm/yyyy hh24"') "';
    on the other
    v_tempc: = col_rec.column_name;
    end if;
    v_tempb: = v_tempb | " ' || Decode('|| col_rec.column_name||',''Null'','||v_tempc||') | " ' ;
    end loop;
    v_tempa: = v_tempa |') values ('| v_tempb |'); "from ' |" tab_rec.table_name | « ; » ;
    end loop;
    If not b_found then
    v_tempa: ='-Table ' | v_table_name | 'not found ';
    on the other
    v_tempa: = v_tempa | Chr (10) | "select"-commit; "double;';
    end if;
    Return v_tempa;
    end;
    /
    display errors

    -STEP 2: run the following code to extract the data.
    Go head
    set pages 0
    game of stripes on
    fixed lines 2000
    the feeding off value
    trigger the echo
    var retline varchar2 (4000)
    coil c:\t1.sql
    Select 'set echo off' from dual;
    Select 'spool c:\recreatedata.sql' from dual;
    Select ' select "-these data was extracted on" | TO_CHAR (sysdate, "mm/dd/yyyy hh24" ") double;' double.

    -The following two lines as repeat as many times as the tables that you want to extract
    exec: retline: = ExtractData ('dept');
    print: retline;

    exec: retline: = ExtractData ('emp');
    print: retline;

    Select 'off spool' from dual;
    spool off
    @c:\t1

    -Step 3: run the updated c:\recreatedata.sql waiting for output to recreate the data.

    Source: http://www.idevelopment.info/data/Oracle/DBA_tips/PL_SQL/PLSQL_5.shtml




    < / pre >

    Hello

    Well what this script do.
    You will pass a table name as input to the function that will return varchar2 (string - insert statement). It will generate 2 t1.sql of sql script that contains the output sequence.

    Will use the first passed the user_tables scipt to check if the input table name exists and if there is the will reterive user_table_columns column names and generate the following sql script.
    Now, this t1.sql will run to generate a final sript formally orders insert that will run you on the target schema (make sure that the table exists).

    * #t1.sql*

    set echo off
    spool recreatedata.sql
    select '-- This data was extracted on '||to_char(sysdate,'mm/dd/yyyy hh24:mi') from dual;
    select 'insert into MY_OBJECT1 ('||chr(10)||'OWNER,'||chr(10)||'TOTAL) values ('||decode(OWNER,Null,'Null',''''||OWNER||'''')||','||chr(10)||''||decode(TOTAL,Null,'Null',TOTAL)||');' from MY_OBJECT1;
    select '-- commit;' from dual;
    spool off
    

    Then @t1.sql runs, and the general insert for the infeed table table.

    -- This data was extracted on 03/09/2009 23:39
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('MDSYS', 92800);
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('TSMSYS', 256);
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('DMSYS', 15104);
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('TESTME', 128);
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('PUBLIC', 2571392);
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('OUTLN', 768);
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('CTXSYS', 21888);
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('OLAPSYS', 78336);
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('KLONDIKE', 2432);
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('SYSTEM', 51328);
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('EXFSYS', 21504);
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('DBSNMP', 4096);
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('ORDSYS', 216192);
    
    INSERT INTO MY_OBJECT1 (OWNER, TOTAL)
      VALUES   ('SYSMAN', 111744);
    
    -- commit;
    

    Hope this helps
    Concerning

  • How can I extract audio from a movie stored on the Photos?

    I have a new 6 iPhone more. Great phone and it records very well.

    On my Mac, OS X 10.11.1 El Capitan

    I used the phone and recently recorded a concert. I had a guy time to get the movies my phone is off. Is there a way to view the files from my phone directory?

    I finally got the film in Photos. Now, I can't do anything with them. I want to extract audio from movies and a CD of the concert.

    I found some third-party software, , but they cannot see the pictures.

    Also, the movies seem to have maxed out my iCloud storage. Another problem, but related. What is the best way to store/backup these images on my computer so that they are accessible from the finder, and will not be removed by synchronization?

    It is a bit nuts, IMO. Should be much more consistent and intuitive.

    Thanks for your help.

    Export the photo sequence: file-> Export, export unmodified: Original

    It's all about Photos.

    Further, use the Image Capture (in the Applications folder) for material like this.

    As for extract the soundtrack. Open the movie in QT player and then export it in Audio-only mode

    Export only the audio using QuickTime Player 10


    QuickTime Player gives you the option to export and share only the audio portion of your video. To export only the audio portion of your video, you can open your video in QuickTime Player. Choose export from the file menu. Type a name in the field "export as. Then on the Format menu, choose 'Audio Only' and click on export

    .

  • 1074118649 error occurred at niUSRP extract data from Rx (2D CBD) .vi

    Hello

    When I was trying the example of the USRP OR which is "niUSRP EX Rx synchronized to multiple entries (MIMO Expansion)", a mistake is released which is

    1074118649 error occurred at niUSRP extract data from Rx (2D CBD) .vi

    A workflow command has been issued in the past.

    can anyboay help me solve the problem?

    Thank you very much

    Andy

    Hi andy,.

    what you need to do is reversing the Oder river where the screw niUSRP the value Time.vi and niUSRP Trigger.vi configure a1.1ppear. Time of first setting then set up trigger. The example works correctly with version 1.1, since you are using version 1.2, that changes must be made.

    In the example, you can set the clock to standard time (start time = 0) even if you had already triggered the reception. Thus, samples received will be acquired with time stamp later where the error.

    Best regards

Maybe you are looking for