Help: how to extract digits from a string?

Hi,
I am trying to make a formatted phone number report. The field is VARCHAR2(20). There might be some sort of irregularities. What I need to do are in two steps:
1. extract all digits in order;
2. format the output as (xxx) xxx-xxxx
Any suggestions?
Thank you in advance.
Jimmy

This might be of some use to clean up the phone numbers.
drop   table phone_numbers;
create table phone_numbers
(phone      varchar2(20));
insert into phone_numbers(phone) values ('(111)-555-1212');
insert into phone_numbers(phone) values (' 111 555 1212');
insert into phone_numbers(phone) values ('#555-1212');
insert into phone_numbers(phone) values ('Bob @ 555-1212');
commit;
select phone, translate(phone,'0123456789()-.@#* ','0123456789') edited_phone
from   phone_numbers;
PHONE                EDITED_PHONE
(111)-555-1212       1115551212
111 555 1212        1115551212
#555-1212            5551212
Bob @ 555-1212       Bob5551212You can see by the last example that the search string in the translate function should contain every character you can type on a keyboard.

Similar Messages

  • How to extract substring from a string based on the condition ??

    Hi,
    I'm having a very large string which as below
    EQD+CN+SAMPLE18767+2200+++5'
    NAD+CA+FIR:172:20'
    DGS+IMD+3.2+2346+55:CEL'
    FTX+AAA+++GOOD'
    FTX+AAA+++ONE'
    EQD+CN+SAMPLE18795+2200+++5'
    NAD+CA+TIR:172:20'
    DGS+IMD+3.2+2346+55:CEL'
    FTX+AAA+++SECOND'
    FTX+AAA+++IS FAIR'
    similarly FTX+AAA as above and it goes on
    i tokenized each segment with delimiter as ' and able to read each segment.
    Now i want to concatenate the FTX+AAA in a single segment if more than one FTX+AAA with IMMEDIATE below
    The output is as follows
    EQD+CN+SAMPLE18767+2200+++5'
    NAD+CA+FIR:172:20'
    DGS+IMD+3.2+2346+55:CEL'
    FTX+AAA+++GOOD,ONE'
    EQD+CN+SAMPLE18795+2200+++5'
    NAD+CA+TIR:172:20'
    DGS+IMD+3.2+2346+55:CEL'
    FTX+AAA+++SECOND,IS FAIR'
    similarly FTX+AAA should be concatenated if it has similar FTX+AAA IMMEDIATE below.
    The FTX+AAA segments can come any number of times immediate below
    Please help me how we can do this??? Can anyone help me with the code snippet to do this?
    Thanks,
    Kathir

    Encephalopathic wrote:
    You've posted > 300 times here and you still don't respect the rule regarding notification of all cross-posts? [http://www.java-forums.org/advanced-java/30061-how-extract-substring-string-based-condition.html]
    Do you think this this will help convince others to help you?See also [http://www.coderanch.com/t/500088/java/java/extract-substring-string-based-condition|http://www.coderanch.com/t/500088/java/java/extract-substring-string-based-condition].

  • How to extract certificates from IE for digital signature

    hi
    how to extract certificates from the cert store provided by Internet Explorer 6.0 and use it to read & verify the digital signatures present in the pc.this is needed in my web based application n i have no idea!!!
    pls help me out
    i have studied a lot about all JCA n JCE but the extraction part still baffles me!!!
    my application will be java based so i can make an applet/ servlet/ jsp
    drop your ideas as soon as u get time as i am stuck in the initial phase itself
    priya_16

    hi
    i've the same problem. i've found this solution, but you need download a JCE Provider that allow you to read the explorer certificate store.
    You can try this one: https://download.assembla.se/jceprovider/
    and the code:
    import se.assembla.*;
    public class Listcerts {  
         public static void list() throws Exception{
              java.security.Security.insertProviderAt(new se.assembla.jce.provider.ms.MSProvider(), 2);
              KeyStore ks = KeyStore.getInstance("MSKS","assembla");
              ks.load(null,null);
              X509Certificate cert=null;
              String alias=null;
              int count=0;
              for (java.util.Enumeration e=ks.aliases();e.hasMoreElements();){
                        alias=(String)e.nextElement();
                        cert=(X509Certificate)ks.getCertificate(alias);
                        System.out.println("\n Certificado alias"+alias+":");
                        System.out.println(cert);
                   count++;
              System.out.println ("NUM CERTS="+count);
    now, i need the same solution for Firefox browser XP
    good luck
    Message was edited by:
    meteko

  • How to extract text from a PDF file?

    Hello Suners,
    i need to know how to extract text from a pdf file?
    does anyone know what is the character encoding in pdf file, when i use an input stream to read the file it gives encrypted characters not the original text in the file.
    is there any procedures i should do while reading a pdf file,
    File f=new File("D:/File.pdf");
                   FileReader fr=new FileReader(f);
                   BufferedReader br=new BufferedReader(fr);
                   String s=br.readLine();any help will be deeply appreciated.

    jverd wrote:
    First, you set i once, and then loop without ever changing it. So your loop body will execute either 0 times or infinitely many times, writing the same byte every time. Actually, maybe it'll execute once and then throw an ArrayIndexOutOfBoundsException. That's basic java looping, and you're going to need a firm grip on that before you try to do anything as advanced as PDF reading. the case.oops you are absolutely right that was a silly mistake to forget that,
    Second, what do the docs for getPageContent say? Do they say that it simply gives you the text on the page as if the thing were a simple text doc? I'd be surprised if that's the case.getPageContent return array of bytes so the question will be:
    how to get text from this array? i was thinking of :
        private void jButton1_actionPerformed(ActionEvent e) {
            PdfReader read;
            StringBuffer buff=new StringBuffer();
            try {
                read = new PdfReader("d:/getjobid2727.pdf");
                read.getMetaData();
                byte[] data=read.getPageContent(1);
                int i=0;
                while(i>-1){ 
                    buff.append(data);
    i++;
    String str=buff.toString();
    FileOutputStream fos = new FileOutputStream("D:/test.txt");
    Writer out = new OutputStreamWriter(fos, "UTF8");
    out.write(str);
    out.close();
    read.close();
    } catch (Exception f) {
    f.printStackTrace();
    "D:/test.txt"  hasn't been created!! when i ran the program,
    is my steps right?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to extract data from web URL

    I was doing one project which need to extract data from web pages and then analyze these data. the question is how to extract data from there, using html parser? need help, thanks a lot

    I was doing one project which need to extract data
    from web pages and then analyze these data. the
    question is how to extract data from there, using
    html parser? need help, thanks a lotTry this:
    http://java.sun.com/docs/books/tutorial/networking/urls/readingURL.html
    Or, like you said yourself, use an HTML parser:
    http://java-source.net/open-source/html-parsers

  • How to extract data from planning book

    nu t apo. need help regarding how to extract data from planning book givn the planning book name , view name & some key figures.
    Total Demand (Key Figure DMDTO):
    o     Forecast
    o     Sales Order
    o     Distribution Demand (Planned)
    o     Distribution Demand (Confirmed)
    o     Distribution Demand (TLB-Confirmed)
    o     Dependent Demand
    Total Receipts (Key Figure RECTO):
    o     Distribution Receipt (Planned)
    o     Distribution Receipt (Confirmed)
    o     Distribution Receipt (TLB-Confirmed)
    o     In-Transit
    o     Production (Planned)
    o     Production (Confirmed)
    o     Manufacture of Co-Products
    Stock on Hand (Key Figure STOCK):
    o     Stock on Hand (Excluding Blocked stock)
    o     Stock on Hand (Including Blocked stock)
    In-Transit Inventory (Cross-company stock transfers)
    Work-in-progress (Planned orders / Process orders with start date in one period and finish date in another period)
    Production (Planned), Production (Confirmed) and Distribution Receipt elements need to be converted based on Goods Receipt date for projected inventory calculation.

    Hello Debadrita,
    Function Module BAPI_PBSRVAPS_GETDETAIL2 or BAPI_PBSRVAPS_GETDETAIL can help you.
    For BAPI BAPI_PBSRVAPS_GETDETAIL, the parameters are:
    1) PLANNINGBOOK - the name of your planning book
    2) DATA_VIEW - name of your data view
    3) KEY_FIGURE_SELECTION - list of key figures you want to read
    4)  SELECTION - selection parameters which describe the attributes of the data you want to read (e.g. the category or brand). This is basically a list of characteristics and characteristic values.
    BAPI_PBSRVAPS_GETDETAIL2 is very similar to BAPI_PBSRVAPS_GETDETAI but is only available from SCM 4.1 onwards.
    For the complete list of parameters, you can go to transaction SE37, enter the function module names above and check out the documentation.
    Please post again if you have questions.
    Hope this helps.

  • How to extract data from ODS to non-SAP system

    Hi,
    Can anybody tell me, step by step, how to extract data from ODS to a non-SAP system?
    Is it possible to do it without programming effort? And is there volume limits for this kind of extraction?
    The non-SAP system is an unix system.
    Thanks in advance
    Ella

    Ella,
    You can look at it from the concept of a BADI / Infospoke
    Extract the data from the ODS to a Flat file / RDBMS using an infospoke. I am not sure as to how the infospoke loads data into the RDBMS ( did it very long ago ) but then you can push it into an RDBMS and I am sure it will be system neutral.
    Hope this helps...
    Arun
    Assign points if it helps

  • How to extract data from custom made Idoc that is not sent

    Hi experts,
    Could you please advise if there is a way how to extract data from custom made idoc (it collects a lot of data from different SAP tables)? Please note that this idoc is not sent as target system is not fully maintained.
    As by now, we would like to verify - what data is extracted now.
    Any help, would be appreciated!

    Hi,
    The fields that are given for each segment have their length given in EDSAPPL table. How you have to map is explained in below example.
    Suppose for segment1, EDSAPPL has 3 fields so below are entries
    SEGMENT          FIELDNAME           LENGTH
    SEGMENT1         FIELD1                   4
    SEGMENT1         FIELD2                   2
    SEGMENT1         FIELD3                   2
    Data in EDID4 would be as follows
    IDOC           SEGMENT                          APPLICATION DATA
    12345         SEGMENT1                        XYZ R Y
    When you are extracting data from these tables into your internal table, mapping has to be as follows:
    FIELD1 = APPLICATIONDATA+0(4)        to read first 4 characters of this field, because the first 4 characters in this field would belong to FIELD1
    Similarly,
    FIELD2 = APPLICATIONDATA+4(2).
    FIELD3 = APPLICATIONDATA+6(2).  
    FIELD1 would have XYZ, FIELD2 = R, FIELD3 = Y
    This would remain true in all cases. So all you need to do is identify which fields you want to extract, and simply code as above to extract the data from this table.
    Hope this was helpful in explaining how to derive the data.

  • How to extract data from oracle database directly in to bi7.0 (net weaver)

    how to extract data from oracle database directly in to bi7.0 (net weaver)? is it something do with EDI? can anybody explain me in detail?
    Thanks
    York

    You can use UDConnect to get from Oracle database in to BW
    <b>Data Transfer with UD Connect -</b>
    http://help.sap.com/saphelp_nw04/helpdata/en/78/ef1441a509064abee6ffd6f38278fd/content.htm
    <b>Prerequisites</b>
    You have installed the SAP WAS J2EE Engine with BI Java components.  You can find more information on this in the SAP BW installation guide on the SAP Service Marketplace at service.sap.com/instguides.
    Hope it Helps
    Chetan
    @CP..

  • JDBC-XI-FILE scenario. How to extract data from more than one table in JDBC

    Hi,
    I was asked a question like in JDBC-XI-FILE scenario........ How to extract data from more than one tables (i.e from JDBC system) ?? What is the logic to do the same ??
    I am not sure whether this is a valid question..........but any help in this regards is highly appreciated.
    Regards
    Kumar

    HI,
    Yes it can be possible ,please see the following links
    JDBC  Receiver with Oracle Stored Procedures
    configuring jdbc adapter with multiple tables
    RFC -> XI -> JDBC Scenario Updating Multiple Tables
    /people/alessandro.berta/blog/2005/10/04/save-time-with-generalized-jdbc-datatypes
    JDBC Adapter multiple Selects
    https://www.sdn.sap.com/irj/sdn/advancedsearch?query=jdbc%20with%20multiple%20tables&cat=sdn_all
    Regards
    Chilla..

  • How to extract data from XML file with JavaScript

    HI All
    I am new to this group.
    Can anybody help me regarding XML.
    I want to know How to extract data from XML file with JavaScript.
    And also how to use API for XML
    regards
    Nagaraju

    This is a Java forum.
    JavaScript is something entirely different than Java, even though the names are similar.
    Try another website with forums about JavaScript.
    For example here: http://www.webdeveloper.com/forum/forumdisplay.php?s=&forumid=3

  • How to extract data from SAP 4.7 and upload data to SAP ECC 6.0

    Hi,
        How to extract data from SAP 4.7 and upload data to SAP ECC 6.0? Can i use BDC,BAPI,LSMW? Help me please.

    hi
    good
    both works not possible simultaneously.
    If you want to do it in two separate task than you can use the GUI_UPLOAD function module to fulfill your requirement.
    thanks
    mrutyun^

  • How to extract Source from  .wda file

    Hi WebDynpro Experts,
    Do you know how to extract source from .wda file. I appreciate your help and will award points for correct answers.
    Thank you
    Maruti CR

    Hi,
    U wont be able to extract source code from wda file.It contains
    only class,xml and mf  files.The only thing that u would be able
    to use is class file which u need to convert to .java file
    by .class to .java converter.
    Hope this will clear ur doubt.Still if u want to try just extract
    wda file using winzip.go on doing this untill u find unzip files.
    Regards
    Surender Dahiya

  • How to Extract data from Oracle DB to BW via DBConncet interface.

    HI All,
    Do you know how to extract data from ORACLE data base to BW, using DBConnect.
    Here we are not using R/3 Business content structures.
    How to do it in both source system  and BW side?
    How to define structures on both sides.
    Please provide any documents on that.
    Thanks in Advance.
    Sri.

    Hi Srilaxmi
    Have a look at these links
    http://help.sap.com/saphelp_nw04/helpdata/en/58/54f9c1562d104c9465dabd816f3f24/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/a1/89786c3df35c4ea930a994e884bb4c/content.htm
    http://help.sap.com/saphelp_bw30b/helpdata/en/80/1a618ae07211d2acb80000e829fbfe/content.htm
    and  this thread
    Extract from Oracle View with DB connect
    regards
    KR

  • How to extract data From Hyperion Essbase to Flat Files

    Hi ,
    Can anyone tell me how to extract data from Hyperion essbase to Flat file(e.g. .csv , .txt ,...) or Oracle Table using ODI.
    Regards,
    Avneet

    Hi sutirtha,
    I have make one column as key column now i am getting this error,
    org.apache.bsf.BSFException: exception from Jython:
    Traceback (innermost last):
    File "<string>", line 1, in ?
    com.hyperion.odi.essbase.ODIEssbaseException: The number of columns returned by script [10] is less than the source data columns exposed [12]
    at com.hyperion.odi.essbase.ODIEssbaseDataReader.getAppData(Unknown Source)
    at com.hyperion.odi.essbase.AbstractEssbaseReader.extract(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java)
    at org.python.core.PyMethod.__call__(PyMethod.java)
    at org.python.core.PyObject.__call__(PyObject.java)
    at org.python.core.PyInstance.invoke(PyInstance.java)
    at org.python.pycode._pyx7.f$0(<string>:1)
    at org.python.pycode._pyx7.call_function(<string>)
    at org.python.core.PyTableCode.call(PyTableCode.java)
    at org.python.core.PyCode.call(PyCode.java)
    at org.python.core.Py.runCode(Py.java)
    at org.python.core.Py.exec(Py.java)
    at org.python.util.PythonInterpreter.exec(PythonInterpreter.java)
    at org.apache.bsf.engines.jython.JythonEngine.exec(JythonEngine.java:144)
    at com.sunopsis.dwg.codeinterpretor.k.a(k.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.scripting(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execScriptingOrders(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execScriptingOrders(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSqlC.treatTaskTrt(SnpSessTaskSqlC.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java)
    at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java)
    at com.sunopsis.dwg.cmd.DwgCommandSession.treatCommand(DwgCommandSession.java)
    at com.sunopsis.dwg.cmd.DwgCommandBase.execute(DwgCommandBase.java)
    at com.sunopsis.dwg.cmd.e.k(e.java)
    at com.sunopsis.dwg.cmd.g.A(g.java)
    at com.sunopsis.dwg.cmd.e.run(e.java)
    at java.lang.Thread.run(Unknown Source)
    Caused by: com.hyperion.odi.essbase.ODIEssbaseException: The number of columns returned by script [10] is less than the source data columns exposed [12]
    at com.hyperion.odi.essbase.wrapper.EssbaseReportDataIterator.validateColumns(Unknown Source)
    at com.hyperion.odi.essbase.wrapper.EssbaseReportDataIterator.init(Unknown Source)
    ... 33 more
    com.hyperion.odi.essbase.ODIEssbaseException: com.hyperion.odi.essbase.ODIEssbaseException: The number of columns returned by script [10] is less than the source data columns exposed [12]
    at org.apache.bsf.engines.jython.JythonEngine.exec(JythonEngine.java:146)
    at com.sunopsis.dwg.codeinterpretor.k.a(k.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.scripting(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execScriptingOrders(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execScriptingOrders(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSqlC.treatTaskTrt(SnpSessTaskSqlC.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java)
    at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java)
    at com.sunopsis.dwg.cmd.DwgCommandSession.treatCommand(DwgCommandSession.java)
    at com.sunopsis.dwg.cmd.DwgCommandBase.execute(DwgCommandBase.java)
    at com.sunopsis.dwg.cmd.e.k(e.java)
    at com.sunopsis.dwg.cmd.g.A(g.java)
    at com.sunopsis.dwg.cmd.e.run(e.java)
    at java.lang.Thread.run(Unknown Source)

Maybe you are looking for