Regular expressions and phone number

Hello
There is a column 'Phone_number Varchar2'
Data containing:
123 89556-6852

-857 (123) - 965

123-5846 5648

I want to display that

123895566852

123857965

12358465648

Pls help by regular Expressions.

Published by: Guillaume on February 17, 2010 15:59
with t
as
(
select '123-89556-6852' phone_no from dual union all
select '(123)-857-965' from dual union all
select '123-(5846)5648' from dual
)
select regexp_replace(phone_no,'[^[:digit:]]') phone_no
  from t

Tags: Database

Similar Questions

  • Name and phone number attached to every comment I make on facebook

    Hello, I noticed that whenever I have comment on a message or photo on facebook that my name and phone number is added, much like a signature. How to stop what is happening please?

    You will need to request support from Facebook. Nothing to do with Microsoft.

  • Delete my old address and phone number of the computer.

    I use a DELL XPS that has loaded Windows XP operating systems.

    When we first bought this computer, we lived in a State different, different home address and telephone number. But we moved to the sunny New Mexico.

    Now, whenever I fill out a form, my 'old' address and phone number fills white and I have to
    constantly to clear the form and manually type in my new address and phone number. It gets old.

    How can I delete/erase my old address and enter the memory on this computer in my new address/phone
    so it will expand sites form with updated contact information.

    Thank you

    mwhunter85

    Try this,

    Tools-internet options-content-auto complete-settings-removed automatic full-tick form data-removal only.

  • Number of shaped with preg_replace Regular Expression and PHP

    Hello

    I would like to add a 'dash' after every 3 digits in a given number (10 digits). For example, 9785678941 became 978-567-894-1. How could I achieve this with regular expression using PHP preg_replace?

    Thank you.

    The next solution is based on the example of "The use of backreferences followed literals digital" published on the php.net site.

    In accordance with the $string, $pattern, $replacement nomenclature which is the php.net example use, here´s my modification:

    <>

    $string = '9785678941';

    $pattern = ' / (\\d{3})(\\d{3})(\\d{3})(\\d{1)} /';

    $replacement = ' ${1}-{2}-${3}-${4}';

    echo preg_replace ($pattern, $replacement, $string);

    ?>

  • Help with the Regular Expressions and regexp_replace

    Oh great guru Oracle can I can receive assistance

    I need to clean the phone numbers that have been entered in the table per_phones of Oracle e-Business. Some of the phone numbers have hyphens, some have spaces and some have tank. I just want to get out all the figures and then re - format the number.

    E.g.
    914-123-1234... out (914) 123-1234
    9141231234... new (914) 123-1234
    914 123 1234... (914) 123-1234
    MyPhone... just null
    (914)-123-1234... (914) 123-1234

    I really tried to understand the instructions of regular expressions, but for some reason, I can't understand it.

    For example:

    SQL> with sample_data as (
      2   select '914-123-1234' phone_number from dual union all
      3   select '9141231234'                from dual union all
      4   select '914 123 1234'              from dual union all
      5   select '(914)-123-1234'            from dual
      6  )
      7  select regexp_replace(
      8           regexp_replace(phone_number, '\D')
      9         , '(...)(...)(....)'
     10         , '(\1) \2-\3'
     11         ) as formatted_num
     12  from sample_data
     13  ;
    
    FORMATTED_NUM
    --------------------------------------------------------------------------------
    (914) 123-1234
    (914) 123-1234
    (914) 123-1234
    (914) 123-1234
     
    
  • Regular expression for invalid number

    Hello world

    I use version oracle as follows:

    SQL > select * from v version $;

    BANNER
    ----------------------------------------------------------------
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - production
    PL/SQL Release 10.2.0.4.0 - Production
    CORE 10.2.0.4.0 Production
    AMT for 32-bit Windows: release 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production

    ------------------------------------------------------------------------

    I use a regular expression to replace invalid values in a table.

    I got oracle error 'ORA-01722 invalid number '.

    My query looks like this:

    SELECT DISTINCT

    MRC_KEY,

    PURPOSE_CD,

    RESIDENCE_DESC,

    TO_NUMBER (regexp_replace (ICAP_GEN_MADAPTIVE, "..?")) 0? 0? (\d+) [-.] ((?', '\1')) as ICAP_GEN_MADAPTIVE,

    Of

    MRRC_INT

    I don't know what are invalid values in the table, so I can write regexp accordingly.

    Any guidance is appreciated!

    Thanks in advance

    J

    Hello

    Whenever you have a problem, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.
    Explain, using specific examples, how you get these results from these data.  View of the code which is not what you want can be useful, but there niot enough by itself.
    See the FAQ forum: https://forums.oracle.com/message/9362002

    Let's look at what you do:

    REGEXP_REPLACE (icap_gen_madaptive

    , '[+. ]' || -exactly 1 of these characters

    '?0?0?' || -up to 2 ' 0 '

    '(\d+)' || -some numbers (it comes to \1)

    '[-.]?'    -0 or 1 of these characters

    , '\1'

    )

    Is it really what you want?  A group of figures don't match, as the patten must start with a sign more, a point or a space.  You want to allow a decimal point at the beginning and at the end, as in "." 9. '?  If there are numbers before and after the decimal point, as in "1.2", you want only the digints before the comma?  You never said what you want, but I'm guessing that these are things that you don't want.

    If the pattern is found, this changes only the schema, so a string like "FU + 123 BAR" more than the model + 9 "" changed to "9" and the resulting string. "" "" FU9BAR"would be passed TO_NUMBER.

    If the pattern is not found, as in "FOO", nothing is changed, and the entire string is passed to TO_NUMBER.

    I suspect you want to use instead of REGEXP_REPLACE REGEXP_SUBSTR, or, if there is stuff to ignore before and/or after the number you want to include in the model, so that REGEXP_REPLACE will be replaced by nothing.

    This looks like a good argument to use the NUMBER of columns to store numbers.

  • How can I stop someone from using my apple ID and phone number to FaceTime on iPad?

    How to prevent a unknown user talk on FaceTime with my Apple and the phone number?

    The first question is: How did get your ID and password? Did you give anyone access?

  • "Matches regular Expression" and "Model match" vi behaves differently

    Hello

    I need a simple matching chain and experimenting that found the "Regular Expression Match' and 'Correspondence model' vi behave a little differently. I guess that the entries of the regular expression on the two the same behavior. It's a difference that I discovered that the "|" character ("vertical" character, commonly used as an operator 'or') is recognized as such in the regex to Match vi, but not in the match vi model (where it is taken to the letter). Furthermore, I can't find any document using (online or in LabVIEW) on the ' | ' usage in regular expressions of character. Is - this documented anywhere?

    For example, suppose I want corresponding to one of the following 4 words: 'The' or 'fast' or 'brown' or 'fox '. The regular expression ' the | fast | Brown | Fox' (without the quotes) works for the vi Regular Expression Match but not the match pattern vi. Here is a photo of the block diagram and the results of the façade:

     

    The Help explains that the vi Regular Expression Match performs a little more slowly the match vi pattern, so I started with the latter. But since he does not work for me, I'll use the old. But does anyone have an idea of the speed difference? I guess that's negligible in a simple example.

    Thank you!

    Thank you, Jeff. That's what I was looking for. BUT my version of LabVIEW 8.5, does NOT say "functionfor example, the Match model does not support the parenthesis or vertical bars (|) characters.«» !

    See: http://zone.ni.com/reference/en-XX/help/371361D-01/glang/match_pattern/

    and http://zone.ni.com/reference/en-XX/help/371361D-01/glang/match_regular_expression/

    It is not mentioned in the help of special characters used for the match pattern : http://zone.ni.com/reference/en-XX/help/371361D-01/lvhowto/specialcharformatchpatt/

    The only place | has 'talked', it is in the sentence: "some regular expressions that use alternating (such as (. |))". \s)*) require significant resources to deal with when it is applied to the large input strings. "But I'm not processing a large chain.

    It seems that NEITHER fixed this omission. What version is your help?

    Ed

  • I get phone calls from "microsoft" and phone number to see if it is legitimate. The India what it seems.

    Bogwe I think, he wouldn't give me any info just kept asking if I was the owner of the account. I had problems with my computer, he said. Not really. No phone number that I could call back to see who it was, really, Miss 1 number on my caller ID. I think that scam and also sounded like he was English Eastern decent, broken. BEWARE! Microsoft you must put a warning message it will last eternally.

    Fake phone calls to technical support

    Calls unrequested telephone of this nature are almost always a common scam. Do not let them give any info, do not give access to your PC, not give them all the money and do not go to all the websites that they suggest. One moment.

    Please see:

    http://www.Microsoft.com/en-GB/security/online-privacy/avoid-phone-scams.aspx

    Microsoft issues never not solicited for phone calls of support or security.

    These types of callers can use completely fictitious names or bogusly claim to be of real companies other than Microsoft as well.

  • The Regular Expressions and GUID.

    Hello gurus, I hope you can help me!
    I need to select GUID from a table and to do this, I need the regular Expression. My
    Perl is not good and not good Regular Expression. My database is Oralce 11.2.0.2.0 and
    Linux (Oracle Version 6) is the operating system of the Machine. If you need further information,
    I'll look closely. Thank you. Jehangir.

    >

    Hi Jehangir and welcome to the forums.

    I need to select the GUID of a table and to do this,

    Well, the first thing we do is read the forum FAQ and also the post by BluShadow
    at the top of the messages on the home page of the forum. You should have provided code (DDL
    and DML) showing your particular problem, but since it's your first time, I'll be gentle ;)

    We have it done - clients have sometimes GUID as PKs, and we need to send data to
    their systems, but it is not as simple as it may first appear.

    GUID may arise in three formats.

    The Oracle one - SELECT Sys_GUID() from DUAL which is just a string of 32 hexadecimal characters.
    Then the chain with the hyphen, then the string with dashes and {} at the beginning and end (see
    examples of data).

    with datax as
    (
      SELECT '79A864CCD8E44CD8B0A2765DF9EF337B' as guid  FROM DUAL  UNION ALL
      SELECT '79A864CFD8E44CD7B0A2765DF9EF337B' FROM DUAL UNION ALL
      SELECT '8gdfsgsgfdg' FROM DUAL UNION ALL  -- dummy for testing
      SELECT '21EC2020-3AEA-1069-A2DD-08002B30309D' FROM DUAL UNION ALL
      SELECT '21EC5550-3AEA-1069-A2FF-08002B30309D' FROM DUAL UNION All
      SELECT '{21CC2020-3AFA-1A69-A2DD-08002B30309D}' FROM DUAL
    )
    
    -- first one is the Oracle format
    select * from datax where regexp_like(guid, '[0-9a-fA-F]{32}'); -- Oracle select sys_guid();
    
    -- second one is with hyphens
    
    select * from datax where regexp_like(guid, '[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}');
    
    -- third one is with hyphens and curly brackets.
    
    select * from datax where regexp_like(guid, '^\{[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}\}$');
    
    -- This converts both of the last two formats back into Oracle format, which is what
    -- we use. Notice, that I haven't used regualar expressions to do this. Regexes are
    -- computationally expensive, and you should use Oracle's string furnctions if possible
    
    SELECT REPLACE(REPLACE(REPLACE(GUID, '{', ''), '}', ''), '-', '')  FROM Datax;
    

    HTH,

    Paul...

    Jehangir.

  • Some edit fields like email and phone number are not captured in Firefox?

    Hello

    I tried to save the email and phone fields, and it does not seem to save the entry in these areas in one Firefox (works fine in IE).

    I had to write the script below to make it work. But no matter what body falls on the question?

    web.textBox (34, "{{obj ATG_repo. SIGNUP_email}}') .keyPress ("abc < SHIFT-2 > example");
    robot.keyPress (KeyEvent.VK_DECIMAL);
    web.textBox (34, "{{obj ATG_repo. SIGNUP_email}} ")." KeyPress ("com");

    I used the text it doesn't that is why I used the KeyPress method. Please suggest if you have other methods

  • My I - phone 5 s is acting funny. I call a friend and she sees "Restricted" at the end instead of my name and phone number.  In addition, sometimes I call someone and the message is "that number is not available.

    My I - phone 5s has problems. I called a friend who has my name in his phone book and she sees on the screen "Restricted."  I try to call someone and I get"this number is not available. I call the company that provides the 'ULTRA' cell phone service and they tell me that I have to remove my caller ID. Yesterday I called a friend who I talked to for several years and my name does not appear on his phone.

    Your problem is a problem of carrier. You will need to go back to them and sorting.

  • Need help on the regular expressions and query

    Hi guru s, I hope that you all made great!

    I have a scenario where I need to insert data into the table.

    I have three scenarios:
    select 'Kodali,Raj,S' str from dual
    union 
    select 'Alex Romano' from dual
    union 
    select 'ppppp' from dual
    
    Alex Romano
    Kodali,Raj,S
    ppppp
    What I want is now.

    1 Alex Romano
    is there space between the chain and then I want to insert in the last name and first name columns
    2 Xavier, Raj, S
    If there is a comma between the chain and I want to insert in the last name, first name and middle name
    3. If there is one channel then insert even in first name and last name.

    I wrote the request more early to manage only by commas and now I'm trying but not able to use this all scenarios
    Can you please help me.
    WITH t AS (
     
    select 'Kodali,Raj,S' str from dual
    union 
    select 'Alex Romano' from dual
    union 
    select 'ppppp' from dual
    
    ) 
    select DECODE(trim(a),NULL,'a',trim(a)),DECODE(trim(b),NULL,'b',trim(b)),decode(trim(c),NULL,'c' ,trim(c)) 
    from 
     (
      SELECT max(decode(level,1,regexp_substr(str,'[^,]+',1,level))) a --INTO lFNAME
              , max(decode(level,2,regexp_substr(str,'[^,]+',1,level))) b --INTO lLNAME
              , max(decode(level,3,regexp_substr(str,'[^,]+',1,level))) c --INTO lMNAME       
       FROM   t
      CONNECT BY regexp_substr(str,'[^,]+',1,level) IS NOT NULL
      GROUP BY str
    ) ;
    Currently I put a b and c if its null value.


    Thanks in advance!

    Hello
    You can do what you asked for in pure SQL like this:

    WITH     got_pos          AS
    (
         SELECT     str
         ,     INSTR (str, ',')     AS comma_pos
         ,     INSTR (str, ' ')     AS space_pos
         FROM     t
    )
    SELECT    str
    ,       CASE
               WHEN  comma_pos > 0
               THEN  REGEXP_SUBSTR (str, '\w+', 1, 2)
               WHEN  space_pos > 0
               THEN  SUBSTR (str, 1, space_pos - 1)
               ELSE  str
           END     AS fname
    ,       CASE
              WHEN  comma_pos > 0
              THEN  REGEXP_SUBSTR (str, '\w+', 1, 3)
              ELSE  TRIM (REGEXP_SUBSTR (str, ' \w+ '))
           END     AS mname
    ,       CASE
               WHEN  comma_pos > 0
               THEN  SUBSTR (str, 1, comma_pos - 1)
               ELSE  REGEXP_SUBSTR (str, '\w+$')
           END     AS lname
    FROM       got_pos
    ORDER BY  str
    ;
    

    But look how it is difficult, even for this simple example of data.

    I suggest you write a PL/SQL function to analyze the name. It will be much easier to deal with a combination of spaces and commas, the names of more than 3 words, etc.

  • Can I set up a signature for all my iMessages with my name and phone number?

    Can I add a signature to all my text messages?

    Jacker says:

    Can I add a signature to all my text messages?

    iMessages - No.

  • Mask a number with regular expressions

    Hi @ll!

    Is it possible to hide a given number

    of "12345678" in "XXXX5678".
    or '987458' to 'XX7458 '.

    with Regular Expressions and without substr()? To display only the last four digits and the 'X' value for the rest. The size of the number is not always the same.

    Alex, I think the OP wanted the first 4 characters to hide ;)

    Something like that?

    select translate(substr('12345678',1,length('12345678')-4),'1234567890','XXXXXXXXXX')
                    || substr('12345678',length('12345678')-3)
              from dual
    /
    TRANSLAT
    --------
    XXXX5678
    

    More

    with test_data as
    (
    select '12345678' card_no from dual
    union all select '123456' from dual
    union all select '5678900' from dual
    ) -- End of test data
    select translate(substr(card_no,1,length(card_no)-4),'1234567890','XXXXXXXXXX') ||
              substr(card_no,length(card_no)-3)
        from test_data
    /
    
    TRANSLATE(SUBSTR
    ----------------
    XXXX5678
    XX3456
    XXX8900
    

    Arun-

Maybe you are looking for