Regular expression to extract the date

Hi all

Please show me how can I extract date of statement, that date has four forms such as
2008-08-08 or 08/08/2008 or 2008-agu-8 or 8.8.2008

the follwing query can extarct in this form 08/08/2008.

SELECT REGEXP_SUBSTR ("the Conference will be on 08/08/2008 ',' [0-9] {1,} / [0-9] {1,} / [0-9] {2,}'") FROM dual;

concerning
Isabelle

Published by: Isabelle on 29 July 2012 10:17

Specifically, he writes that

the date has four following forms: 2008-08-08 or 08/08/2008 or 2008-agu-8 or 8.8.2008

then why you will keep nagging on 10/11/12?

@OP: here is a starting point, as I understand it:

with dirtydates as (
select 1 myrow, 'The date is 8.8.2012' mydate from dual union all
select 2 myrow,  'The date is 19.Aug.2012' mydate from dual union all
select 3 myrow,  'The date is 20-08-2012' mydate from dual union all
select 4 myrow,  'The date is 21-8-2012' mydate from dual union all
select 5 myrow,  'The date is 22/8/2012' mydate from dual)

select myrow, mydate,  regexp_substr (mydate , '[0-9]{1,2}[[:punct:]]([0-9]{1,2}|[[:alpha:]]{3})[[:punct:]][0-9]{4}' ) datesubstr
from dirtydates
order by 1
;

     MYROW MYDATE                  DATESUBSTR
---------- ----------------------- -----------------------
         1 The date is 8.8.2012    8.8.2012
         2 The date is 19.Aug.2012 19.Aug.2012
         3 The date is 20-08-2012  20-08-2012
         4 The date is 21-8-2012   21-8-2012
         5 The date is 22/8/2012   22/8/2012              

5 rows selected.

It's a regular expression simple-thing. You can use: punct: or the list of the ones you want, like [.-/]

Tags: Database

Similar Questions

  • Use regular expressions to extract .llb file from the path name

    I'm trying to be smart (always a dangerous thing) and use a regular expression to extract the name of a library to a filepath converted to a string.   While I appreciate there are other ways to do this, regex seems to be a very powerful way of neat, I would be able to operate.

    IE, if I have a string of type, C:\applications\versions\library.llb\toplevel.vi, I want to be able to extract the library.llb of the string, because it will be of variable length, may include the numbers & spaces and may be located in a file of variable depth hierarchy.   In other words, I want to extract the part of the string between the last-which ends with .llb

    The best I managed so far is \\+.*llb who all returned less the drive letter and the toplevel.vi

    Can someone help me to achieve this goal, or I'm better by using an alternative method (for example filepath string in array, search for .llb)

    Thank you

    Matt

    Hi Matt,

    attached you will find two other options.

    Mike

  • regular expression to remove the zeros on the right

    I need a regular expression to remove the zeros after the decimal point. I tried (?.)<=\.\d+?)0+(?=\D|$) but="" i="" get="" a="" error="" about="" look="" behind="" not="" a="" fixed="" length="" or="" something="" like="" that.="" i="" am="" not="" a="" regex="" expert="" and="" i="" was="" wondering="" just="" how="" to="" do="" this="" with="" regular="" expression="" or="" some="" other="">

    Z.K. wrote:

    [...] or some other way.

    I tried and I tried but I couldn't crack with a regular expression, so I took the easy way.  The first match found pattern the comma and the other removes the zeros to the right of the rest.  It is not discriminate between numbers and all the rest, though.

  • Foglight v6 - FaultException: impossible to extract the data of inventory of the collector

    After having modernized our virtual center to V4, the foglight fails to report all the details and only has the following alert:
    "FaultException: impossible to extract the data of inventory of the collector: the parameter name cannot be null or an empty string."
    ' Parameter name: key to make sure the collection agent service is running.
    If anyone else has had this problem and how to solve?
    Thank you
    Karim

    Hi Joviyach,
    I logged a call with Vizioncore and the resolution is as follows:
    the problem you have is related to a VMware problem experienced during the upgrade to vSphere 4.0 as detailed in: kb.vmware.com/.../search.do
    Bascially, you must run a SQL command of your Virtual Center via MS SQL Management Studio that will identify one or more VMs who have a missing entry in the VPX_VIRTUAL_SCSICONTROLLER table. Once this information is determined that you would follow the steps 2 to 6 of the reolution... basically remove these virtual machines of the inventory and adding them back.
    When these steps are complete, you will re-start the vFoglight Collector of Vmware and Vmware vFoglight connector services.

  • Using regular expressions to store the first 3 letters of a string

    Can anyone help with regular expressions?

    The problem:

    I have a contact field which is holder of a value of campaign here is an example of how we look at:

    EMC | TEACHER | HRSUB | June2012-may-01

    I need to store the first three letters of the code in another field of contact, the first three letters are not a defined value and may change in different codes.


    I have next to no experience with regular expressions, so I am struggling to set up cloud connector Eloqua - here's a screenshot:

    A few tips on how to set up?

    This should do the trick, although I would recommend that make you a few tests more using http://regexpal.com/

    ^|\| (.*)$

    Chris

  • Regular expression TO validate the name of column

    Hi all

    I want to write a regular expression to validate the name of column names.i.e enterted must follow the convention of valid column name
    contain only A - Z, a-z, 0-9, _, $, and #.

    Please someone help me to do this.
    Padma

    Hey padma.

    Regular expression TO validate the name of column

    to set jaspx for example in the Validation number:

    **

    If your use na na... chain mention you model as etc. from A to z...

    otherwise if the two method nt answer using java Scrpit na... it's better ground for you.

    If however hepatitis is any querys na msg me... If possible I try best,.

    Thnks,
    Suresh V

    Published by: V Suresh on April 2, 2012 16:55

  • extract the date year

    Hello

    IAM using obiee 11g, hold extract the date year
    CAST (YEAR ("ABC". "DATEADDED") as varchar (4)) "
    so used like that

    But I want as if the year is 11 2011 then only I want y at - it a direct function that does this.

    Thank you

    You can use the right right function (year 2). Will return 11 if the year 2011

  • How can I use a regular expression to validate the email address

    How can I use a regular expression to validate the e-mail address.

    var emailExp:RegExp = /([a-z0-9._-]+?) @([a-z0-9.-] +). ([a - z] {2,4});

  • Need help to extract the data into a string of separate brackets

    Hello

    I have a scenario where I have to extract data into a string that is enclosed in [].

    Here's what I want to do...

    entry:

    [name_first] [name_mi] [name_last]

    required output: this must return all data that are placed between square brackets.
    name_first
    name_mi
    name_last

    I tried the "REGEXP_SUBSTR' but my version of the database is 9i, and it is available only from 10 g.

    Thanks in advance.

    Hello

    You can use SUBSTR and INSTR
    This should work in Oracle 9:

    WITH     cntr     AS
    (
         SELECT     LEVEL     AS n
         FROM     dual
         CONNECT BY     LEVEL <= 3
    )
    ,     got_pos          AS
    (
         SELECT     x.txt
         ,     c.n
         ,     INSTR (x.txt, '[', 1, c.n)     AS l_pos
         ,     INSTR (x.txt, ']', 1, c.n)     AS r_pos
         FROM           table_x  x
         CROSS JOIN    cntr     c
    )
    SELECT        txt
    ,        n
    ,        SUBSTR ( txt
                   , l_pos + 1
                , r_pos - (l_pos + 1)
                   )     AS sub_txt
    FROM        got_pos
    ORDER BY   txt
    ,             n
    ;
    

    Sorry, I don't have an Oracle 9 database now; I had to test this in Oracle 10.

    jimmy437 wrote:
    ... I tried the "REGEXP_SUBSTR' but my version of the database is 9i, and it is available only from 10 g.

    It's true. Regular expressions are very useful, but they are not available in Oracle 9 (or earlier).
    Oracle 9 has a package supplied by Oracle, OWA_PATTERN, which provides regular expression features:
    http://docs.Oracle.com/CD/B12037_01/AppDev.101/b10802/w_patt.htm
    I know it's the Oracle 10, documentation, but there are in Oracle 9, too.

    Oracle 9 is very old. You should consider the upgrade.

  • Extract the data from the ReadyNAS Duo 3 to disk?

    Hello

    I have a ReadyNAS Duo chassis crashed with two drives of 3 TB in it. Both discs seem to work very well.

    How can I do to retrieve the data from disks of theses? they were in a RAID 1 configuration, so I guess I just need to extract one of the disks. Does it matter which drive is it?

    I started to connect one of the disks to an installation of Ubuntu and I can find from the disc with respect to the available partitions, but I get no info on the file system used, only that it is flagged as RAID.

    Because I don't want ot destroy all the data I was very careful when working with the partitioning tool. So far, I've installed and looked parted, gparted, gdisk and a few others.

    Since I'm really new to Linux, I need more detailed assistance with indicators to be used to access the drive.

    Any input is highly appreciated.

    Christoffer

    Look at this: http://kb.netgear.com/app/answers/detail/a_id/29961?utm_source=community&utm_medium=announcement&utm...

  • Extracting the data from QVariantMap

    I have the following data :

    QVariant (QVariantMap, QMap ((' data', QVariant (QVariantMap, QMap ((' current_condition', QVariant (QVariantList, ((QVariantMap, QMap... QVariant QVariant (QVariantMap, QMap ((' weather', QVariant (QVariantList, ((QVariantMap, QMap... QVariant QVariant (QVariantMap, QMap ((' weather_desc', QVariant (QVariantList, ((QVariantMap, QMap... QVariant

    m_model-> insert(data.value() .value ("data") .toMap ().value("weather").toList () .at (0) .toMap ());

    Using the above line, I am able to extract relevant data from "current_condition and"weather".

    What should I add to the line above to also extract data from 'weather_desc '?

    Any help would be appreciated. Thank you.

    Thank you! It is much easier to read when formatted, it's the first thing I did.

    { "data":
      {
        "current_condition":
        [
          {
            "cloudcover": "0",
            "humidity": "18",
            "observation_time": "02:36 AM",
            "precipMM": "0.0",
            "pressure": "1007",
            "temp_C": "39",
            "temp_F": "102",
            "visibility": "10",
            "weatherCode": "113",
            "weatherDesc": [ {"value": "Sunny" } ],
            "weatherIconUrl": [ {"value": "http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0001_sunny.png" } ],
            "winddir16Point": "N",
            "winddirDegree": "10",
            "windspeedKmph": "46",
            "windspeedMiles": "29"
          }
        ],
        "request":
        [
          {
            "query": "Melbourne, Australia",
            "type": "City"
          }
        ],
        "weather":
        [
          {
            "date": "2013-01-04",
            "precipMM": "0.0",
            "tempMaxC": "37",
            "tempMaxF": "98",
            "tempMinC": "19",
            "tempMinF": "66",
            "weatherCode": "113",
            "weatherDesc": [ {"value": "Sunny" } ],
            "weatherIconUrl": [ {"value": "http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0001_sunny.png" } ],
            "winddir16Point": "N",
            "winddirDegree": "3",
            "winddirection": "N",
            "windspeedKmph": "21",
            "windspeedMiles": "13"
          }
        ]
      }
    }
    

    To access weatherDesc in usage by time:

    Data.value.value("data").toMap ().value("weather").toList () .at (0) .toMap ().value("weatherDesc").toList () .at (0) .toMap .value ("value") ())

    This will return "Sunny."

    For readability, I suggest if this string to:

    QMap  dataMap = data.value().value("data").toMap();
    
    QList weatherList = dataMap..value("weather").toList();
    
    QVariant firstWeatherEntry = weatherList.at(0);
    
    QMap weatherEntryMap = firstWeatherEntry.toMap();
    
    QList weatherDescList =
    weatherEntryMap.value("weatherDesc").toList();
    
    QVariant firstWeatherDescEntry = weatherDescList.at(0);
    
    QMap weatherDescEntryMap = firstWeatherDescEntry.toMap();
    
    QString value = weatherDescEntryMap.value("value").toString(); // "Sunny"
    

    Also, you can check intermediate outcomes at each stage by calling

    qDebug()< weatherlist="">< "\n";="" and="" so="">

  • extracts the date of a DD-MON-RR part

    I would like to extract and compare only the part of the date to a date, for example, I would like to know if an entrydate is equal or less than 9/1.

    But the date of the entry are all format DD-MON-RR. How to remove the part of the year and compare only the part of the month and day?

    Select entrydate

    students

    where... < 9/1 - here is the part he needed to work on.

    Thank you
    a large part

    Hello

    Something like

    WHERE TO_CHAR (entrydate, "MMDD") > '0901'

    I hope that answers your question.

    If this isn't the case, 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.

    Include special cases, you need to manage; for example, entrydate is exactly 1 September (before or after him), or entry_date is 06:00 on 1 September.

    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: Re: 2. How can I ask a question on the forums?

  • Portlet cannot extract the data

    Hello

    I created an adf application that retrieves data from the Employees table.

    I run to the local wls and everything works fine.

    I created an entry portlet.

    I have deployed my portal (right click on the application--> deploy...).

    I created a page to add my portlet here.

    I ran the page and it is impossible to extract all the data.

    From the console, I had a reference of message incomplete connection for connection object: op

    Any ideas how I can retrieve the data?

    Christos

    The first thing that the error message complains of a connection named "op" while your server has set 'opekepeDS '. Second thing, it is that jdbc, data sources are defined with a tiny "jdbc" instead of the uppercase 'JDBC' you used.

    Check the connection of the application. The name of the data source must match the name defined on the server.

    Timo

  • Regular expression to remove the space in the HTML tag

    Hi all

    My HTML string is as below.

    Select ' < CityName > RICHMOND < / Nom_ville >< StateCd > ABCD CDE< StateCd / >< CtryCd > CAN < / CtryCd >< CtrySubDivCd > BC < / CtrySubDivCd > ' double Str

    Output desired is

    < CityName > RICHMOND < / Nom_ville > < StateCd > ABCD CDE< StateCd / > < CtryCd > CAN < / CtryCd > < CtrySubDivCd > BC < / CtrySubDivCd >

    I want to remove these spaces of the tag value box with only spaces otherwise leave it as what. Please help to implement the same using regular expressions.

    Hello

    We don't know what you want.  This site seems to be formatting your message in a weird way.

    As the statement

    SELECT «...» "THE DOUBLE;

    without formatting, to show your entry and after the exact output desired friom as, with as little in shape as possible.  It might be useful if you use some character like ~ instead of spaces (just for viewing; we will find a solution that works for spaces).

    To remove the text which consists of spaces and nothing else between the tags, you can say

    REGEXP_REPLACE (str

    , '> +<>

    , '><>

    )

    How is this string generated?  Maybe there is an easier and more effective way to keep the bad wrtings sub off the chain in the first place.

  • Impossible to extract the data of an additional column in the table advance

    Hello

    We have an obligation to add an extra column to the table of advanced search. In addition, we need sort the table using this additional column.

    Now, we have achieved the following:

    1. the required VO was already extended previously and the additional column (LAST_UPDATE_DATE) is already present in the definition of the EO. So, we just added the tag for LAST_UPDATE_DATE in YOUR XML in the form:

    < ViewAttribute

    Name = "LAST_UPDATE_DATE".

    IsPersistent = "false".

    Type = "Oracle.jbo.domain.date"

    ColumnType = "DATE".

    AliasName = 'LAST_UPDATE_DATE. '

    Expression = "LAST_UPDATE_DATE."

    SQLType = 'DATE' >

    < / ViewAttribute >

    2 added a new MessageStyledText column, and updated the following property:

    Prompt = LastUpdateDate. Discover the Instance = TaskPerzSumVO. Display attribute = LAST_UPDATE_DATE. Sort Allowed = true

    The field is now visible in table advance and whenever we seek, attaches the value as ' 1901-01-01'. While I checked manually in the respective table, we have the appropriate data. But in the front end we do not get the data in our additional column of table in advance. In addition, if we try to sort the table by clicking the column LAST_UPDATE_DATE, we get the NPE error. Spec of NullPointerException is as follows:

    # # 0 in detail

    1. java.lang.NullPointerException

    at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:989)

    Kindly help us to obtain the appropriate data in the additional column. Thank you!

    Kind regards

    Zahid

    Hi Zahid,

    This is the error:

    29000: unexpected exception caught: oracle.jbo.NoObjException, msg = Houston-25003: TaskEO.LAST_UPDATE_DATE object of type entity activity not found

    Tag entity by its use should have only name of EO and not the name of the attribute.

    Use instead under the tag:

    EntityUsage = "TaskEO".

    Also, I mentioned that rather tags manually, add it please try Wizard VO to add this attribute in EO attributes available list.

Maybe you are looking for