Parse and extract a Canadian Address and Phone# from a Text Varchar2 field

Happy Remembrance/Veterans Day everyone.
I have a "data migration" issue in my hand and there is a Text field that now needs to be organized nicely into proper address fields.
So far, I have been able to parse the Postal Code correctly from the text field which is storing the address.
SELECT code, address, regexp_substr(address,'[A-Z]\d[A-Z] *\d[A-Z]\d') postal_code
FROM student_tb
WHERE REGEXP_LIKE(address,'[V]\d[A-Z] *\d[A-Z]\d');
I still have to extract the Address and sometimes a Phone number which is all stored in one field. Here are 4 examples and acceptable formats:
#2115-101 Adelaide Street East Toronto ON M5A 1N1 (416) 767-0912
Testing ABC #2101-212 King Street West, Toronto, ON, M5A 4T1
#3114-212 Bloor Street E      Toronto    ON   M3C1S1  651-1213
HOTEL PANAORAMA      Waterloo    ON   M1A 2A1
Script for table creations:
create table student_tb
    code     varchar2(4),
    address varchar2(500)
create table student_address_tb
  code           varchar2(4),
  address_type   varchar2(1),
  hotel_name     varchar2(50),
  street         varchar2(50),
  city           varchar2(50),
  province       varchar2(2),
  postal_code    varchar2(10),
  phone          varchar2(10)
Inserting records into table student_tb:
insert into student_tb values('1001','#2115-101 Adelaide Street East Toronto ON M5A 1N1 (416) 767-0912');
insert into student_tb values('1002','Testing ABC #2101-212 King Street West, Toronto, ON, M5A 4T1');
insert into student_tb values('1003','#3114-212 Bloor Street E      Toronto    ON   M3C1S1  651-1213');
insert into student_tb values('1004','#HOTEL PANAORAMA
Toronto
ON   M1A 2A1');
create table city_gis(city_name varchar2(50));
insert into city_gis values('Toronto');
insert into city_gis values('Waterloo');
insert into city_gis values('Barrie');
The above 4 records from student_tb need to be transferred over to the student_address_tb.
Assumptions:
1. Address can be detected when it starts with a # sign.
2. City will be picked up based on the table city_gis. So, the street will not contain the City.
3. Province will be detected as 'ON'
4. Phone numbers will be starting with numbers or a bracket followed by number and should not contain any letters.
For phone numbers, I attempted with this but I am not sure I am picking it up correctly. In fact, its picking up the address of the Apartment.
select address, regexp_substr(address,'[[:digit:]]+( ?)(-?)( ?)[[:digit:]]+( ?)(-?)( ?)[[:digit:]]+')
from   student_tb;
Any help in this regard would be great.
Thanks!

FrankKulash wrote:
Aren't Canadian phone numbers always 10 digits (where the first 3 digits are soemtimes implied), and separators, when used, only occur after the 3rd and 6th digits?
Being Canadian myself, I can answer this   Should be always 10 (sometimes 11 if somebody insists on tacking the "assumed" 1 on the front). Seperators *should* occur after the 3rd and 6th, however, I've seen all kinds of crazy ..
Parsing phone #'s has to be one of the harder things business keep asking us to do O_o (since everyone insists on entering them in their own way) *sigh*
On another note, I did get the following working, however, as Frank says, not sure what it'll do on a large data set
with w_data as (
         select '#2115-101 Adelaide Street East Toronto ON M5A 1N1 (416) 767-0912  ' data from dual union all
         select 'Testing ABC #2101-212 King Street West, Toronto, ON, M5A 4T1      ' data from dual union all
         select '#3114-212 Bloor Street E      Toronto    ON   M3C1S1  651-1213    ' data from dual union all
         select 'HOTEL PANAORAMA      Waterloo    ON   M1A 2A1                     ' data from dual
      w_data1 as (
         select data,
         regexp_replace(data, '^(.*?)[ ,]+([A-Za-z]+)[ ,]+([A-Z]{2})[ ,]+([A-Z]\d[A-Z] *\d[A-Z]\d)[ ,]+(.*?)$', '\1::\2::\3::\4::\5')  data_parsed
         from w_data
Select regexp_substr(data_parsed, '[^:]+', 1, 1) address,
       regexp_substr(data_parsed, '[^:]+', 1, 2) city,
       regexp_substr(data_parsed, '[^:]+', 1, 3) province,
       regexp_substr(data_parsed, '[^:]+', 1, 4) postal,
       regexp_substr(data_parsed, '[^:]+', 1, 5) phone
   from w_data1
ADDRESS                                  CITY                 PROVINCE   POSTAL               PHONE
#2115-101 Adelaide Street East           Toronto              ON         M5A 1N1              (416) 767-0912
Testing ABC #2101-212 King Street West   Toronto              ON         M5A 4T1
#3114-212 Bloor Street E                 Toronto              ON         M3C1S1               651-1213
HOTEL PANAORAMA                          Waterloo             ON         M1A 2A1

Similar Messages

  • Forgot to sign out of old id and changed icloud email address and cant sign out of find my phone

    I have a iphone 4s and changed icloud email address and forgot to sign out of find my phone. How can I turn it off to change to the new email address that I changed in icloud?

    To change the iCloud ID you have to go to Settings>iCloud, tap Delete Account, provide the password for the old ID when prompted to turn off Find My iDevice, then sign back in with the ID you wish to use.  When you do this you may find that the password for your old ID isn't accepted.  If this should happen, and if your old ID is an earlier version of your current ID, you need to temporarily recreate your old ID by going to https://appleid.apple.com, click Manage my Apple ID and sign in with your current iCloud ID.  Click edit next to the primary email account, change it back to your old email address and save the change.  Then edit the name of the account to change it back to your old email address.  You can now use your current password to turn off Find My iDevice on your device, even though it prompts you for the password for your old account ID. Then save any photo stream photos that you wish to keep to your camera roll.  When finished go to Settings>iCloud, tap Delete Account and choose Delete from My iDevice when prompted (your iCloud data will still be in iCloud).  Next, go back to https://appleid.apple.com and change your primary email address and iCloud ID name back to the way it was.  Now you can go to Settings>iCloud and sign in with your current iCloud ID and password.

  • I want to enter the password for a secure WIFI network on several iphones.  If I do this, can the end users somehow extract the ip address and password for the wifi network from the iphone and use it from a pc (at home, for example)?

    I want to enter the password for a secured wifi network on several iphones.  If I do this, is it possible for the end users to somehow extract the ip address and password information and use it from a pc/laptop/other mobile device.  For security reasons, I don't want them to be able to to this.
    Please advise,
    Thanks.

    If you look at the top left of your screen you will either see a 3G (or 4G if you have AT&T) or you will see the wi-fi symbol.  If you don't see the wi-fi symbol you are connecting to Gmail through your cellular data plan, not via wi-fi.
    To answer your question, it doesn't happen often but when it does the steps I mentioned above will normally resolve it.  Hopefully you won't have any further problem with this.

  • I want to copy and paste a long list of phone numbers into the 'to' field of messages. Ideas?

    I want to copy and paste a long list of phone numbers into the 'to' field of messaging. All it does is become one long number instead. I have even tried commas in between. Any ideas? (They are NOT contacts)

    That's not how iMessage was designed to work.  It works with your contacts.  You start typing a phone number or email address and you'll se a list of hint from auto-complete.  After you select a suggestion, start typing another address.  If the addresses you want are not in your contacts, you'll need to enter each of them manually.

  • Is it possible to download iOS  5 from one iMac and not get them totally wiped of apps and stuff. We have an iPad each and a communal email address and an iCloud address each. One iPad now is totally screwed up.

    Is it possible to download iOS  5 from one iMac on two ipads and not get them totally wiped of apps and stuff. We have an iPad each and a communal email address and an iCloud address each. One iPad now is totally screwed up.

    Thank you for your reply.
    I am somewhat new to iOS and OS having grown up with DOS and Windows. I am not familiar with IMAP and iCloud and I am not even sure which types of servers my various emails use.
    The problem I would anticipate with iCloud is that (I assume) it would limit my access to data (including mail) on the iCloud to when I happen to be logged onto the internet. I also assume(?) that large files (photos etc.) would require some time to download whenever I wish to access them from whichever device I happen to be using (I hope I am wrong about this).
    I have kept my devices to 500gb - 1TB for OS and 32gb - 128gb for iOS but since I have pretty slow WiFi (shared with DirecTV Whole Home and Netflix streaming) it is my impression that iCloud might be quite limited due to data transfer times.
    Perhaps a factor would be that I have 2 DSL lines and my main DSL line is connected to two wireless routers (to also provide WiFi in a metal building that blocks WiFi and Cellular signals)
    I may be totally wrong in my assumptions regarding iCloud. My mail is not so urgent that I need access to it instantly and I could wait until I had internet access or I can get it on my iPhone. My main concern with iCloud would be my data files (Word, Pages, Excel, Numbers etc.).
    On the other hand, if I wanted to keep my 10,000 emails that would take up a lot of iCloud memory and I don't know how to measure how much storage it would take or how to move Hotmail or even iCloud mail to iCloud.
    It may take me some time to figure this out.

  • How can I read the bootstrap files and extract the fragment-URLs and fragment-numbers in plain text?

    How can I read the bootstrap files of any HDS Live stream and extract the fragment-URLs and fragment-numbers in plain text?
    Could it be that it is some kind of compressed format in the bootstrap? Can I uncompress it wirh  f4fpackager.exe? Could not find any download for f4fpackager.exe. I would prefere less code to do so. Is there something in Java of JavaScript, that can extract the fragment-numbers?
    Thank you!

    Doesn't sound too hard to me. Your class User (the convention says to capitalize class names) will have an ArrayList or Vector in it to represent the queue, and a method to store a Packet object into the List. An array or ArrayList or Vector will hold the 10 user objects. You will find the right user object from packet.user_id and call the method.
    Please try to write some code yourself. You won't learn anything from having someone else write it for you. Look at sample code using ArrayList and Vector, there's plenty out there. Post in the forum again if your code turns out not to behave.

  • HT201269 My wife switched from an iPhone 4 to an iPhone 5.  Everything transferred over and service is on the new phone.  However, texts are going to her old phone still.  Any idea what the problem is?

    My wife switched from an iPhone 4 to an iPhone 5.  Everything transferred over and service is on the new phone.  However, texts are going to her old phone still.  Any idea what the problem is?

    As long as iMessage is enabled and the old phone is connected to a WiFi access point, it will continue to receive iMessage texts. It won't receive non-iMessage texts nor will it receive any calls.

  • HT204380 I cant set up my facetime in a new iPod touch 5 generation, I enter my apple id and password and select my email address and it get verification but after that it come back to enter my apple id and password again. please help

    I cant set up my facetime in a new iPod touch 5 generation, I enter my apple id and password and select my email address and it get verification but after that it come back to enter my apple id and password again. please help

    This is the iPhone forum

  • So i sent 2 PXTs to someone and it came up on their phone from 2 different numbers and none of them mine. I called those numbers and they were just normal people and they had no idea what had happened. How did this happen?

    So i sent 2 PXTs to someone and it came up on their phone from 2 different numbers and none of them mine. I called those numbers and they were just normal people and they had no idea what had happened. How did this happen?
    Both phones were iPhone 4s and everyone was with different carriers.

    Simple process. If an iPhone go to the Apple Store and not Verizon
    the phone from Verizon will be a refurbished device and not new unless under the 14 day worry free guarantee
    good luck

  • How to extract Weblogic Listen Address and port.

    Hi All,
    I want to extract Weblogic Admin server's Listen address and port via Java to perform some admin actions.
    Can someone please help on this.
    Thanks,
    GJ

    Hi,
    Try this code.
    import java.io.IOException;
    import java.net.MalformedURLException;
    import java.util.Hashtable;
    import javax.management.MBeanServerConnection;
    import javax.management.MalformedObjectNameException;
    import javax.management.ObjectName;
    import javax.management.remote.JMXConnector;
    import javax.management.remote.JMXConnectorFactory;
    import javax.management.remote.JMXServiceURL;
    import javax.naming.Context;
    import java.lang.*;
    public class ServerDetails
    private static MBeanServerConnection connection;
    private static JMXConnector connector;
    private static final ObjectName service;
    static
    try {
    service=new ObjectName("com.bea:Name=DomainRuntimeService,Type=weblogic.management.mbeanservers.domainruntime.DomainRuntimeServiceMBean");
    catch (MalformedObjectNameException e)
    throw new AssertionError(e.getMessage());
    public static void initConnection(String hostname, String portString,String username, String password) throws IOException,MalformedURLException
    System.out.println("ServerDetails---Started in initConnection");
    String protocol="t3";
    Integer portInteger=Integer.valueOf(portString);
    int port=portInteger.intValue();
    String jndiroot="/jndi/";
    String mserver="weblogic.management.mbeanservers.domainruntime";
    JMXServiceURL serviceURL=new JMXServiceURL(protocol, hostname,port, jndiroot + mserver);
    Hashtable h=new Hashtable();
    h.put(Context.SECURITY_PRINCIPAL, username);
    h.put(Context.SECURITY_CREDENTIALS, password);
    h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES,"weblogic.management.remote");
    connector=JMXConnectorFactory.connect(serviceURL, h);
    connection=connector.getMBeanServerConnection();
    public static ObjectName[] getServerRuntimes() throws Exception
    return (ObjectName[]) connection.getAttribute(service,"ServerRuntimes");
    public void printServerDetails() throws Exception
    ObjectName[] serverRT=getServerRuntimes();
    for (int i=0;i < serverRT.length;i++)
    String name=(String)connection.getAttribute(serverRT,"Name");
    String listenAddress=(String)connection.getAttribute(serverRT[i],"ListenAddress");
    Integer listenPort=(Integer)connection.getAttribute(serverRT[i],"ListenPort");
    System.out.println("Server Name : " + name +"\t Address: "+listenAddress+"\t Port: "+listenPort);
    public static void main(String[] args) throws Exception
    System.out.println("ServerDetails---Started");
    String hostname=args[0];
    String portString=args[1];
    String username=args[2];
    String password=args[3];
    System.out.println("Hostname : " + hostname);
    System.out.println("PortString : " + portString);
    System.out.println("Username : " + username);
    System.out.println("Password : " + password);
    ServerDetails sd=new ServerDetails();
    initConnection(hostname, portString, username, password);
    sd.printServerDetails();
    connector.close();
    Regards,
    Kal

  • My iPad Air 16 gb wifi  not open and asking for an address and not mine and I am the owner of this device and I can not pave if there is a possibility of me to help me open it with my address as I opened before

    asking for an address and not mine and I am the owner of this device and I can not pave if there is a possibility of me to help me open it with my address as I opened before

    Read the following about, "Activation Lock".
    http://support.apple.com/kb/ht5818

  • How do I get all the control buttons in one place in 3.6.16, like they used to be in previous versions? Having the refresh and stop buttons between address and search windows, and the home button to the far right is awful.

    In 3.6.16, the buttons are all over the place. In previous versions, the forward, back, refresh, stop and home buttons were all together. In this version, the refresh and stop buttons are between the address and search windows, and the home button to the far right.
    I would love to have them all together as they used to be - much more user friendly that way. I have tried installing alternate themes, but the coding of this version over-rides the themes.

    Firefox 4.0 has a combined Reload and Stop and Go button that appears at the right end of the location bar.
    To restore the Firefox 3 appearance you can use these steps:
    * Open the "View > Toolbars > Customize" window to move the Stop and Reload button out of the location bar.
    * Move the Reload and Stop buttons to their previous position at the left side of the location bar.
    * Set the order to "Reload - Stop" to get a combined "Reload/Stop" button.
    * Set the order to "Stop - Reload" or separate them otherwise to get two distinct buttons.

  • Internet Explorer app and place of the addresses and tools bars

    Hi
    I noticed that, when I run the Internet Explorer app on Windows 8.1 Update, the addresses and tools bars are placed in the bottom of the IE screen.
    It is possible to place them at the top of this screen? If so, how do I do it?
    Thanks
    Bye
    Balubeto

    Yes, as I know, we're unable to change the location of the address bar of Modern IE.
    Yolanda Zhu
    TechNet Community Support
    OK. I hope that, with Windows
    8.2, the location of the bars in Modern
    IE can be moved.
    A curiosity: Using the mouse in Modern IE,
    how do I quickly return to my home page?
    Thanks
    Bye
    Balubeto

  • HT3529 How do I sent text messages to me as an email?  I have tried this by chosing Edit, then putting a check mark next to the text to send, entered my email and it goes back to the phone as a text msg, never comes to my email in box?

    I have tried to send a text that I received to my email address by hitting, Edit then placing a check mark next to the text to send, entered my email address and hit the send icon.  Three times, the email has come to me as a text and never appears in my email inbox.   Help please!

    I think you're asking this:
    You received a text message.  Now you would like to copy the text message's information and receive it as an email.
    You would do that by copying the text message to your clipboard (hold down the text bubble and select "Copy"), creating an email message, and pasting that text into the body of the email message and sending it.

  • I lost my apple id and my e-mail address and i can not open it

    I lost my apple ID and my e-mail address
    I want to open my i pad

    If your iPad is on the activation screen then you will have to remember or find your account, if you can't then you won't be able to reactivate and use the iPad.
    Do you have any of the account's downloads in your computer's iTunes library : Recovering a forgotten iTunes Store account name ?
    If not then have you tried finding your id via http://appleid.apple.com : Apple ID: How to find your Apple ID ?
    If you find or remember your account id and you can't remember its password then you can get it reset via http://iforgot.apple.com

Maybe you are looking for