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!!!

Similar Messages

  • 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

  • How can I remove non-numeric characters from a cell?

    I have a file an rtf file that I can open in Numbers. It puts each line in a separate cell. Each cell contains non-numeric and numeric characters. I'd like to delete the non-numeric characters so that I can add the numbers together. Is there a way to do this easily in Numbers that doesn't require doing it manually?
    Thanks,
    David

    Ok, David,
    This solution will work for vlaues up to 99,000 and if there is a space in front of your amount. There are two parts for clarity but you could wrap them up into one formula if you wanted to.
    B2 =FIND(" ",A2,LEN(A2)−9)
    C2 =MID(A2,B2,10)
    If there is a return before your amount (certain cells in your screenshot got me wondering) then the formula in column B
    =FIND("
    ",A2,1)
    It looks funny because it is finding the return.
    Let me know if this works for you.
    quinn

  • Removing non printable characters from an excel file using powershell

    Hello,
    anyone know how to remove non printable characters from an excel file using powershell?
    thanks,
    jose.

    To add - Excel is a binary file.  It cannot be managed via external methods easily.  You can write a macro that can do this.  Post in the Excel forum and explain what you are seeing and get the MVPs there to show you how to use the macro facility
    to edit cells.  Outside of cell text "unprintable" characters are a normal part of Excel.
    ¯\_(ツ)_/¯

  • Removing Non-Ascii Characters from a String

    Hi Everyone,
    I would like to remove all NON-ASCII characters from a large string. For example, I am taking text from websites and would like to remove all the strange arabic and asian characters. How can I accomplish this?
    Thank you in advance.

    I would like to remove all NON-ASCII characters from a large string. I don't know if its a good method but try this:
    str="\u6789gj";
    output="";
    for(char c:str.toCharArray()){
         if((c&(char)0xff00)==0){
              output=output+c;
    System.out.println(output);
    all the strange arabic and asian characters.Don't call them so.... I am an Indian Muslim ;-) ....
    Thanks!

  • Removing non-English characters from data.

    Ours is global system with some data with non-English characters. We want to download file by removing this non-English characters.
    Any suggestions how we can remove these non-English characters from file..?

    The FM u said
         Replace non-standard characters with standard characters
       Functionality
         SCP_REPLACE_STRANGE_CHARS processes a text so that it only contains
         simple characters. Special characters and national characters are
         replaced in such a way that the text remains reasonably legible.
         The character set 1146 is used by default. In this case the following
         replacements are made, for example:
          Æ ==> AE        (AE)
          Â ==> A         (Acircumflex)
          Ä ==> Ae        (Adieresis)
          £ ==> L         (sterling)
         Note that the new text can be longer than the old.
    So i dont think it ll be useful for eliminating the sp. chars.
    U have to check each and every alphabet with std 26 alphabets
    Thanks & Regards
    vinsee

  • Removing non english characters from my string input source

    Guys,
    I have problem where I need to remove all non english (Latin) characters from a string, what should be the right API to do this?
    One I'm using right now is:
    s.replaceAll("[^\\x00-\\x7F]", "");//s is a string having chinese characters.
    I'm looking for a standard Solution for such problems, where we deal with multiple lingual characters.
    TIA
    Nitin

    Nitin_tiwari wrote:
    I have a string which has Chinese as well as Japanese characters, and I only want to remove only Chinese characters.
    What's the best way to go about it?Oh, I see!
    Well, the problem here is that Strings don't have any information on the language. What you can get out of a String (provided you have the necessary data from the Unicode standard) is the script that is used.
    A script can be used for multiple languages (for example English and German use mostly the same script, even if there are a few characters that are only used in German).
    A language can use multiple scripts (for example Japanese uses Kanji, Hiragana and Katakana).
    And if I remember correctly, then Japanese and Chinese texts share some characters on the Unicode plane (I might be wrong, 'though, since I speak/write neither of those languages).
    These two facts make these kinds of detections hard to do. In some cases they are easy (separating latin-script texts from anything else) in others it may be much tougher or even impossible (Chinese/Japanese).

  • Remove of non-printable characters from string

    Hi Gurus,
    How can I achive that? I have a string in which sign "end of line" occurss. How can I delete them?
    BR
    Marcin Cholewczuk

    Hi Marcin,
    Just use a [REPLACE|http://help.sap.com/abapdocu_70/en/ABAPREPLACE.htm] with a regular expression (Assuming variable STRING holds your data):
    replace all occurrences of regex '[\n\r]+' in STRING with ''.
    Note that I replaced newline ('\n') - also called end of line - and carriage return ('\r') with nothing (matching your delete request). This might not be wanted if you have a true multiline string. If you're more paranoid and want to cover more cases, you might want to replace any non-displayable characters using '\[\[:print:\]\]+' as your search pattern. So if you want to replace non-displayable characters with a space and just kill it at the end of the string you could use something like this:
    replace all occurrences of regex '[^[:print:]]+(?!$)' in STRING with ` `.
    replace all occurrences of regex '[^[:print:]]+$' in STRING with ''.
    Cheers, harald

  • Removing unicode control characters from string

    Hi.
    I have a webservice where I return an object (with some strings) back to the client. The information is read from a database, and the string can sometimes contain invalid xml characters (like unicode 0x13). This results in an error when parsing the information at the client side.
    Is there someway a easy way to set up a filter or something that checks whether the string contains characters outside the valid range specified for XML's (lower than unicode 0x20 etc), and removes them/replace them with a different character?

    If you have to get rid of the control chars then       String someText = "a\nb\nc\td\re\r\nf";
            String someTextWithoutControlChars = someText.replaceAll( "[\u0000-\u0020]","");
            System.out.println(someTextWithoutControlChars);but like kaj says, some control chars are valid.

  • Removing last 2 characters from string field

    I am trying to remove the last 2 characters of a string field.
    there is no consistant length in the field
    316R1
    12364R1
    i want to remove everything after R
    i tried instrrev but i that didnt do it.
    is there a way to say
    start position1 and go the R
    thanks

    formula,
    left (field, length_formula) is the solution
    the length_formula is the number of chars form left
    f.i
    left(field, length (field)-2)
    left (field, InstrRev, field,"R")
    of course a combination with Right is also possible

  • Safari "tel:" phone number links stripping non-numeric characters

    After a week of owning my iPhone (two weeks after it launched) I made myself a little web interface that contain various iPhone-helpful links. Four of these were AT&T specific telephone links:
    *646# - check how many minutes remaining
    *729 - pay your bill
    etc etc..
    (e.g. <a href="tel:*729">click here to pay your bill</a>)
    Well, needless to say this was a very convenient feature, however these links no longer function properly. It seems that the iPhone is now stripping any/all non-numeric characters from the link (although I haven't done extensive testing to see exactly which characters .. only with * and $ in particular).
    I've even tried HTML entities but they were stripped too.
    Now I know apple had a security fix a few patches back, one that fixed a vulnerability involving "tel:" links (CVE-2007-3755), but I haven't found any documentation regarding special characters now being ignored/stripped.
    So, my question is does anyone know if there is a workaround for this, or did the patch inadvertently and permanently destroy the ability to send these very helpful text messages via a web interface?
    Thanks,
    Marc

    I'm having a similarly annoying behavior with "tel:" links. I'm doing the same thing -- writing a web page to store some convenient numbers, but for me, it's for teleconference numbers. You dial into a toll-free number, then after a pause, dial in a passcode.
    On the iPhone's contact list, you can program in the pauses as the letter "p."
    However, in a tel: link, the p's change to 7's. Interesting!
    What I've discovered is that, for me (FW 1.1.2), alphabetical characters are translated into their numerical equivalents. So 1-800-COMCAST (a number I've had to dial all too much recently) gets rendered to 18002662278.
    This is a difference between Safari 3 and the iPhone version. On Safari 3 on the Mac, both the HTML and a mouseover shows that the tel link contains the letters. On the iPhone, though, clicking the link brings up a dialog box with the letters "translated."
    So, interesting -- but now I have a problem. How do I enter a pause into a tel link?

  • Need help in removing non printable characters

    hi
    I am having an issue with non printable characters in webservice. This webservice dishes out xml in B2B communication to my clients programs. Due to data corruption in oracle (dont know who is creating bad data ) I am having non printable characters in the xml file which is generated from database. I am dishing out this to our customers. since the data in updated every day it is imposible to fix the data every time. I need to write a very very effficient method to strip non printable characters from strings from the xml. Can some one Please help on this one. I want to make sure this method is very efficient because this method could be potentially be called lots of times. I am using JDK 1.3.1 and oracle 8i
    Any help will be appreciated
    Thanks
    Ashok Pappu

    At some point you existing program is probably converting from String data to the XML bytes through a CharsetEncoder, probably inside a java.io.Writer.
    Perhaps your best approach might be to write your own java.nio.charset.CharsetEncoder which deals with the bad characters as you see fit.
    You can register a new java.nio.charset.CharSet as a private character set type. Because this should result in simply replacing a standard CharsetEncoder with a non-standard one hopefully the overheads would be low.

  • Select only non-numeric characters

    A
    $
    ^
    (78^*)5$#7
    )!@#$0-99
    _454*(&--0
    +@#$%564
    =123
    How select only non-numeric characters from above table?

    Nilesh Hole,Pune, India wrote:
    but i want a uniqe query.
    suppose table have n number of rows then how i will wirte a query.Not sure what you mean? Do you want to select a list of distinct non-numeric characters used in your table? Then:
    column "Distinct non-numeric chars" format a30
    with t as (
               select '!' a from dual union all
               select '@' from dual union all
               select '#' from dual union all
               select '$' from dual union all
               select '%' from dual union all
               select '^' from dual union all
               select '&' from dual union all
               select '*' from dual union all
               select '(78^*)5$#7' from dual union all
               select ')!@#$0-99' from dual union all
               select '_454*(&--0' from dual union all
               select '+@#$%564' from dual union all
               select '=123' from dual union all
               select '135790' from dual
    select  distinct substr(a,column_value,1) "Distinct non-numeric chars"
      from  (
             select  regexp_replace(a,'[[:digit:]]') a
               from  t
               where not regexp_like(a, '^[[:digit:]]+$')
            table(
                  cast(
                       multiset(
                                select  level
                                  from  dual
                                  connect by level <= length(a)
                       as sys.odcinumberlist
    Distinct non-numeric chars
    +
    =
    $
    Distinct non-numeric chars
    ^
    14 rows selected.
    SQL> SY.

  • 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

  • Remove all non-number characters from a string

    hi
    How i can remove all non-number characters from a column ? for example , i have a column that contains data like
    'sd3456'
    'gfg87s989'
    '45/45fgfg'
    '4354-df4456'
    and i want to convert it to
    '3456'
    '87989'
    '4545'
    '43544456'
    thx in adv

    Or in 9i,
    Something like this ->
    satyaki>
    satyaki>with vat
      2  as
      3    (
      4      select 'sd3456' cola from dual
      5      union all
      6      select 'gfg87s989' from dual
      7      union all
      8      select '45/45fgfg' from dual
      9      union all
    10      select '4354-df4456' from dual
    11    )
    12  select translate(cola,'abcdefghijklmnopqrstuvwxyz-/*#$%^&@()/?,<>;:{}[]|\`"',' ') res
    13  from vat;
    RES
    3456
    87989
    4545
    43544456
    Elapsed: 00:00:00.00
    satyaki>
    {code}
    I checked this with minimum test cases. It will be better if you checked it with other cases.
    Regards.
    Satyaki De.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Maybe you are looking for

  • More Questions on Rules in General

    Okay so here is my situation.  I have a user that is wanting to use either Public folders or a shared mailbox to automate a series of manual processes.  For example: A customer service rep(CSR) takes a call asking for x to be completed. CSR than send

  • Set fast_start_mttr_target

    Hello All, I am using Oracle 11gR2 (11.2.0.3). I want to select the value optimal_logfile_size from v$instance_recovery. To do that i need to set the parameter fast_start_mttr_target. My question is there any disadvantage of setting this parameter? i

  • Having trouble loading photos on Craigslist

    having trouble loading photos from iphoto to craigslist ad

  • Cache Invalidation

    How/where do I need to invalidate the cache for the Access Manager when a user id is added to a uniqueMember attribute in the group? With Access Manager 7.0, patch 5: Here's the story: I have a policy with a rule that blocks access to URLs that match

  • Downloaded iOS 8.1.1 and Health data has been wiped out

    I've been diligently loading information into the Health app and after the iOS 8.1.1 upgrade, it's back to a clean slate.  Anyone know if the data is in the cloud and can be recovered?