Numeric literal from string

Hi,
I have a string which contains the name of the customer, followed by phone number. There is no specific length for the name part and the tel number( I cannot use the substring method directly). The tel number is sometimes followed by address( cannot take the last 10 chars as the tel num either).
I need to parse the string for customer's name and tel number. Is there a way to identify the numeric literal from the string?
If I can identify the first numeric in the string, the next 10 characters would be the tel number!

Have a look at the String method charAt(), and the static Character method isDigit(). Between them these will let you decide whether or not the string starts with a digit.
If that doesn't help you need to be clear about (and describe clearly) the structure of the string you are parsing. It sounds like it could have one of the following forms (but I could be wrong about this):<name length unknown><10 digit phone>[optional address length unknown]
<10 digit phone>[optional address length unknown]<name length unknown>Assuming the name consists of non digit characters, the phone number is the first 10 digit characters in the string. It would appear to be impossible to parse the name in the second case (unless you know it always starts with a digit).

Similar Messages

  • Removing non-numeric characters from string

    Hi there,
    I need to have the ability to remove non-numeric characters from a string and I do not know how to do this.
    Does any one know a way?
    Example:
    Present String: (02)-2345-4607
    Required String: 0223454607
    Thanks in advance

    Dear NickM
    Try this this will work...........
    create or replace function char2num(mstring in varchar2) return integer
    is
    -- Function to remove Special characters and alphebets from phone no. string field
    -- Author - Valid Bharde.(India-Mumbai)
    -- Date :- 20 Sept 2006.
    -- This Function will return numeric representation.
    -- The Folowing program is gifted to NickM with respect to his post on oracle site regarding Removing non-numeric characters from string on the said date
    mstatus number :=0;
    mnum number:=0;
    mrefstring varchar2(50);
    begin
    mnum := length(mstring);
    for x in 1..mnum loop
    if (ASCII(substr(upper(mstring),x,1)) >= 48 and ASCII(substr(upper(mstring),x,1)) <= 57) then
    mrefstring := mrefstring || substr(mstring,x,1);
    end if;
    end loop;
    return mrefstring;
    end;
    copy the above program and use it at function for example
    SQL> select char2num('(022)-453452781') from dual;
    CHAR2NUM('(022)-453452781')
    22453452781
    Chao!!!

  • Extracting numeric data from string

    Dear all,
    how can i extract a numeric part of a Varchar2 column..
    the data is
    transaction 111.98 sucess
    gsdhgadg 52365.878 hdfjhfd
    ttqweqwg3321.7676jdshfjhsf
    from all the above strings i want to extract 111.98 ,52365.878 ,3321.7676
    how can i do it in teh most efficient way.. is theer any analytical function inplace for doing this?
    please help..

    edogt wrote:
    hi,
    this is my solution:
    declare
    anumber varchar2(100) ;
    text varchar2(100) := 'transaction. 111.98 sucess' ;
    begin
    anumber := regexp_substr(text,'[[:digit:]]+(\.[[:digit:]]+)*');
    dbms_output.put_line(anumber);
    end ;Which doesn't work if you test it against the OP's latest requirement...
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select 'transaction 111.98 sucess' as txt from dual
      2       union select 'gsdhgadg 52365.878 hdfjhfd' from dual
      3       union select 'ttqweqwg3321.7676jdshfjhsf' from dual
      4       union select 'IT2 Power Resis;UPI 2.4900;QTY10' from dual)
      5  -- end of test data
      6  select txt, regexp_substr(txt, '[0-9]+\.[0-9]+') as num
      7            , regexp_substr(txt,'[[:digit:]]+(\.[[:digit:]]+)*') as num2
      8* from t
    SQL> /
    TXT                              NUM                              NUM2
    IT2 Power Resis;UPI 2.4900;QTY10 2.4900                           2
    gsdhgadg 52365.878 hdfjhfd       52365.878                        52365.878
    transaction 111.98 sucess        111.98                           111.98
    ttqweqwg3321.7676jdshfjhsf       3321.7676                        3321.7676
    SQL>P.S. you should wrap your code with {noformat}{noformat} tags so that it's displayed properly.  ;)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Stripping numeric value from string

    I have a field in my database that stores the following information related to an invoice:
    _FieldName_
    Invoice  9999 for client ABC on 021909.pdf
    Invoice 10000 for client DEF on 032309.pdf
    Invoice 10001 for client GHI on 041209.pdf
    etc...
    I would like to strip the string and return just the invoice number in SQL.  I need to add the sql statement into my Add Command in Crystal.
    Any suggestions on how I can do this?
    Thanks in advance,
    Zack H.

    Thank you all for posting a viable solution.
    This also worked:
    SELECT SUBSTRING(FieldName,  CHARINDEX(' ', FieldName)+1
                   , (CHARINDEX(' ', FieldName, CHARINDEX(' ', FieldName)+1)) - (CHARINDEX(' ', FieldName)+1)
    FROM myTable
    Regards,
    Zack H.

  • Get numerical values from 2D array of string

    Hello! 
    I start by saying that I have a base knowledge of LabView. I'm using LabView 2011. I'm doing some communications test via Can-Bus protocol. As you can see in pictures of the block diagram and of the front panel that I've attached I'm using "Transmit Receive same Port" LabView example. It works very good but I would need to insert the 8 data bytes that I receive from the server in 8 different numerical variables so that I could use them to make some operations. How can I get numerical values from the 2D array of string that I attached? 
    Every example that you can provide is important! 
    Thank you very much! 
    Attachments:
    1.jpg ‏69 KB
    2.jpg ‏149 KB

    Hi martiflix,
    ehm: to unbundle data from a cluster I would use the function Unbundle(ByName)…
    When you are new to LabVIEW you should take all the FREE online resources offered by NI on their website!
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Removing non-alpha-numeric characters from a string

    How can I remove all non-alpha-numeric characters from a string? (i.e. only alpha-numerics should remain in the string).

    Or even without a loop ?
    Extract from the help for the Search and Replace String function :
    Right-click the Search and Replace String function and select Regular Expression from the shortcut menu to configure the function for advanced regular expression searches and partial match substitution in the replacement string.
    Extract from the for the advanced search options :
    [a-zA-Z0-9] matches any lowercase or uppercase letter or any digit. You also can use a character class to match any character not in a given set by adding a caret (^) to the beginning of the class. For example [^a-zA-Z0-9] matches any character that is not a lowercase or uppercase letter and also not a digit.
    Message Edité par JB le 05-06-2008 01:49 PM
    Attachments:
    Example_VI_BD4.png ‏2 KB

  • Using substring to pick the numeric value from a string failing

    Hi,
    I have a string like fffd_1234.com from this I need to pick the numeric value from which is in between the _ and . , for that I have wriiten the expression as
    Reverse(SUBSTRING( REVERSE( "fgfg_asdd.com" ),
    FINDSTRING(Reverse( "fgfg_asdd.com" ), ".", 1 )+1 ,findstring(
    Reverse( "fgfg_asdd.com" ),"_",1 )-FINDSTRING(Reverse("fgfg_asdd.com"
    ), ".", 1 )-1))
    This is throwing me the error or its giving me with the result with _123.

    Why all the "reverse" calls?  Do you expect underscores or periods to occur more than once in the file name?
    This should work:
    SUBSTRING("fffd_1234.com", FINDSTRING("fffd_1234.com", "_", 1) + 1, FINDSTRING("fffd_1234.com", ".", 1) - FINDSTRING("fffd_1234.com", "_", 1) - 1)
    Talk to me now on

  • Removing Non-numeric characters from Alpha-numeric string

    Hi,
    I have one column in which i have Alpha-numeric data like
    COLUMN X
    +91 (876) 098 6789
    1-567-987-7655
    so on.
    I want to remove Non-numeric characters from above (space,'(',')',+,........)
    i want to write something generic (suppose some function to which i pass the column)
    thanks in advance,
    Mandip

    This variation uses the like operators pattern recognition to remove non alphanumeric characters. It also
    keeps decimals.
    Code Snippet
    CREATE FUNCTION dbo.RemoveChars(@Str varchar(1000))
    RETURNS VARCHAR(1000)
    BEGIN
    declare @NewStr varchar(1000),
    @i int
    set @i = 1
    set @NewStr = ''
    while @i <= len(@str)
    begin
    --grab digits or (| in regex) decimal
    if substring(@str,@i,1) like '%[0-9|.]%'
    begin
    set @NewStr = @NewStr + substring(@str,@i,1)
    end
    else
    begin
    set @NewStr = @NewStr
    end
    set @i = @i + 1
    end
    RETURN Rtrim(Ltrim(@NewStr))
    END
    GO
    Code to validate:
    Code Snippet
    declare @t table(
    TestStr varchar(100)
    insert into @t values ('+91 (8.76) \098 6789');
    insert into @t values ('1-567-987-7655');
    select dbo.RemoveChars(TestStr)
    from @t

  • Scan from string error 85

    Hi Everybody,
    I'm trying to use LabView to
    process some data.  The data, although it was collected via labview,
    has been written out to csv file format.  I have been able to
    successfully open the file and use the search split string function to
    remove the "header" from the data stream.  Now I'm trying to parse the
    header to extract some pieces of the info that is there.  I'm trying to
    do this with the Scan from String VI.  
    So
    far I've been able to retrieve the Specimen ID from the first line of
    the header by setting the format string input of Scan from String as
    "Specimen ID ,%s", which works just fine.  Problem is, when I
    adjust
    the format string to include the next piece of data I want, I
    inevitably get an Error 85, which is a failed scan.  In fact, I
    get an err85 every time I try to extract something from after the
    second line.  I've attached a VI in which I cut and pasted an
    example header string in as a string constant and an example of how I'm
    trying to extract the values.  I've tried playing around with
    spaces and different formats, but get the err85 no matter what I do
    (unless I extract the first line).  I have a hunch that it has
    something to do with the EOL marker, but no idea how to work around it.
    A search of posts here show that a lot of people have issues with the
    scan from string vi, but nobody I could find had this exact
    problem.  I've also considered using the spreadsheet spring to
    array function, but because I have a mix of commas and EOLs it doesn't
    seem to work either. HELP! I really don't want to have to write this
    over in VBA/Excel.
    Thanks,
    Turk
    Message Edited by YoungTurk on 07-29-2005 10:36 AM
    Attachments:
    Scan.vi ‏12 KB

    You should probably parse it line by line (See attached, LabVIEW 7.1)..
    The attached example shows one possibility to get all the Items and values out. Not all values are strictly numeric so you would need to adapt the code a little bit. (This is just a very rough 1 minute draft).
    You might want to cosider to extract all values into a cluster for further processing, Have a look at the example  posted in this thread . It can be easily adapted to read the values in the proper format (DBL, I32, Date, String, etc.) depending on the item name.
    Good luck!
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    ScanMOD.vi ‏30 KB

  • How do I avoid Error 85 in Scan From String scanning VISA read buffer?

    I have encountered an Error 85 with my Scan From String VI. I have a timed
    loop to read data from a device (flowmeter) using a serial port. This device takes
    periodic measurements and sends the reading which contains a numerical value to the serial port COM1. It cannot be read continuously, and the period
    between measurements may vary, so I decided a timed loop would be better than a while loop.
    The VI begins with VISA Configure Serial Port and then
    goes to a VISA Write which sends the message to the device to begin
    taking measurements. After this, the device usually says "TAKE FLOWMETER READINGS" to the terminal, thereafter only sending numbers. Then begins my timed loop containing VISA Read. I
    am taking the read buffer two places.
    First, I am taking it to an Array to Spreadsheet String with the
    Format String %.3f, as was in the Write to Text File example. Then I am
    using Concatenate Strings with this string and also a string containing
    the System Time. This string goes to Write to Text File, which I have
    configured using Open/Create/Replace File outside of the loop.
    Second, I am taking the read buffer to a waveform chart. I thought
    it would be a good idea to use Scan From String to convert the string
    into a DBL which I am then sending to the waveform
    chart.
    I am not sure if the initial "TAKE READINGS" message is giving me an error. I was able to get one reading saved to my text file from the device.
    Also the format string for my Scan From String is %.3f
    I am getting the Error 85 at the Scan From String only sometimes.
    When this happens, there is no data being written to the text file. But
    other times, I get data and it writes to the text file just fine (but
    rounds to nearest whole number).
    Any help would be greatly appreciated! This serial port device has been giving me a lot of trouble.

    Is this what you mean? Did I wire the shift registers correctly?
    I didn't know if you meant to Concatenate before Scan From String or Concantenate before or after VISA Read?
    Message Edited by YeungJohn on 11-20-2008 03:48 PM
    Message Edited by YeungJohn on 11-20-2008 03:49 PM
    Attachments:
    SerialShiftVI.JPG ‏87 KB

  • Scan from string in pda

    Hello. 
    I work with LV 7.1, with the I Modul of PDA. 
    It doesn't work me 'Scan From String'. I have not found any contradiction because the pda doesn't accept it. 
    Does somebody know which the cause can be? As I can substitute it? 
    Thank you. 
    Greta
    Attachments:
    scan from string.JPG ‏6 KB

    Hello Greta
    The Scan from string function is supported in LV PDA but with some restrictions. The help file for LV PDA tells us:
    'The Format Into String function and the Scan From String function do not support changing the numeric separator (such as %#;). The Scan From String function does not support wildcard matches.'
    You are changing the numeric separator and this is not supported.
    Hope this helps
    BelenS

  • Scan from string with %g - result not accurate

    I am trying to use the "Scan from String" VI to convert a string into a number.  I am using "%g" as the format specifier.  The conversion is only grabbing the first six significant digits, yet I need it grab all significant digits.  Is there a real limitation here?  What could I do to solve this issue?
    I have attached a simple VI to demonstrate what I'm seeing.
    Thanks,
    Joel
    Attachments:
    Scan_from_String_Example.vi ‏7 KB

    It is because the display format for your numeric indicator is set for 6 significant digits.  Adjust the display format for the indicator and you will see that the other digits are there.

  • Separation of Numbers from string

    Hi All,
    In my project i have a requirement where i need to remove the numerical values from the given string ...
    For ex My input:CLWMEK0299
    Expected Output : CLWMEK
    Kindly please let me know ASAP... '
    Thanks and regards,
    Sudarshan
    Edited by: Sudarshan on Mar 28, 2012 9:51 PM

    Look at this SQLPLUS:
    SQL> select regexp_replace('123abc', '[0-9]','') from dual;
    REG
    abc
    SQL> select regexp_replace('1a7bc', '[0-9]','') from dual;
    REG
    abc
    SQL> create table T ( Text varchar2(20));
    Table created.
    SQL> insert into T values ('12abc345');
    1 row created.
    SQL> insert into T values ('abc12345');
    1 row created.
    SQL> insert into T values ('123abc');
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select regexp_replace(Text, '[0-9]','') from T;
    REGEXP_REPLACE(TEXT,'[0-9]','')
    abc
    abc
    abc
    IN OBIEE front end - Suppose in the column formual of column - Prod_desc - You have to use evaluate function - like this -
    EVALUATE ('REGEXP_REPLACE(%1,%2,%3)',"PRODUCTS"."PROD_DESC",'[0-9]','')

  • Extract date from string in T-SQL

    Hi,
    I am having one field(AT_TEXT) in my database that has below kind of values. I want to extract date from this string but the issue is all rows has different format.
    1)One Month Lttr sent on 3/12/2009 due to
    2)One Month Letter sent on 1/15/2009 due to
    3)One Month letter sent on7/15/2011.The amount due             - This has no space between on and 7 and . after yr
    4)One Month letter sent on 7/16/12 due to        - This has 12 instead of 2012(2 positions after 2nd slash/)
    Can anyone please help me to write query to extract date from this string?
    Vicky

    Hi Jingyang
    Li,
    I checked your query and it looks good but I have one issue. So when we reverse it, it looks like below and it is talking that $57.80 as a 1st numeric value and try to convert it into date and giving me error.
    I realize from your query that you are trying to reverse the value and then try to find out 1st Numeric value from that string, but my whole string has another numeric value at the end, like 
    "One Month Letter on 1/15/2009 due to non-pmt of prems-amt to avoid DE is $57.80"
    So when we reverse it, it looks like below and it is taking that $57.80 as a 1st numeric value and try to convert it into date and giving me error.         
    "08.75$ si ED diova ot eud tma - smerp fo tmp-non ot eud 9002/51/1 no retteL htnoM enO"
    Also sometimes I have $ amount at the end and sometimes I don't have any $ amount at the end, like below,
    "One Month letter sent on 10/15/2012 due to non-payment of premiums. The amount due to avoid dise"
    Can you please modify your query which takes only date part not the $ amount and give me?
    Thank you so much for your help 
    Vicky

  • Delete all non-numc from string

    Guys,
    I want to remove all non-numeric characters from my string. Basically only want it to contain numbers before I pass it on.
    Suggestion?

    parameters: ch(10) type c.
    data: ch1(1) type c.
    data: ty type DD01V-DATATYPE.
    data: l type i.
    DATA: K TYPE I.
    l = strlen( ch ).
    k = 0.
    while k < l.
      ch1 = ch+k(1).
      CALL FUNCTION 'NUMERIC_CHECK'
      EXPORTING
        STRING_IN        = ch1
    IMPORTING
       STRING_OUT       = ch1
       HTYPE            = ty.
      if ty NE 'NUMC'.
    ch+k(1) = '#'.
    endif.
    k = k + 1.
    endWHILE.
    REPLACE ALL OCCURRENCES OF  '#' in CH with ''.
    WRITE: CH.

Maybe you are looking for

  • Problem with opening some of PDFs in Photoshop CS6.

    Hi, I have a problem with opening some of PDFs in Photoshop CS6. It is said: it isn't possible to carry out an order since the module of the file format cannot analyse this file

  • Problems converting any form of document in PDF Generator

    Hello, Could anybody help. I have successfully installed the PDF Generator 7.0.2 on an Windows server 2003 Standard edition. When I put documents into the In folder, I understand, it is supposed to convert the document to another format in the out fo

  • Unable to deploy a web service

    Hello, I am facing a problem while creating a web service for my project. I think it is becoz of the framework i am using.I have deployed my project using Jaxcent Framework but unsble to create a web service for it in netbeans. I have tried using bot

  • "put dependent files" file name in dialog

    <good> When I'm doing a Save All, and I get the dialog asking to put dependent files... this dialog pops up for each of the files to be saved. </good> But,  I don't see anywhere on it the name of which file I'm trying to put in this instance.  (It di

  • Drop down problem -javax.faces.FacesException: Can't instantiate class: ''.

    Hi, I am using jsf 1.1 I am trying to populate a simple drop down in MyJsp.jsp with the List values generated in ContactsListBean.java. I am copying the code here for reference. when I launch the page (forwarding to this MyJsp.jsp in index.jsp) I am