RegExp string transform help

Hello

My version of Oracle: 11G

Here is a string I get in a flat file:

2009-01 - 01 T 14: 02:02.789

My requirement is to transform in 2009-01-01 14:02:02

(1) T must be replaced by a space

point 2) and the characters that follow must be replaced by null

PS: I realized using multiple functions, but you are looking to do this using a function only, I guess regexp_replace might help me thereby or is it does nothing else.

Concerning

Rahul

One more way!

regexp_replace ('2009 - 01-01 T 14: 02:02.789 ',' t |) () \. [[ : digit :]] * $) «, » ')

Tags: Database

Similar Questions

  • String conversion help please

    Hi all

    I'm trying to convert the following text:

    ROOM_NUMBER

    MMA-A13_03
    MMA-B13_04
    BOWL - 23 C
    BOWL - 16 C
    CUP-06F

    Select distinct replace (replace (substr (ROOM_NUMBER, instr (ROOM_NUMBER, '-'), 10), '-'), '_', '-') table Short_Room;

    A13-03
    B13-04
    23 C
    16 C
    06TH

    If the first character is a letter that replace it with anything?

    i.e.

    A13 - 03 will become 13-03

    Hmm... You can play a little yourself with REGEXP with the help of Solomon.
    Replace (REGEXP_REPLACE (regexp_replace(room_number,'^[^-]+-\a{0,1}'), '[A - Z].'), '_','-')

  • Hexadecimal string parsing help

    Hi I have a problem with this problem. I use XBEE in API mode and features how it works it sends a string of package API containing the address, length, and data. I have no problem separating those is just when the data comes. If devices expires or is interrupted by another node, it sends the packet but it cannot send a complete data package. For example, it is just part of the data that it sends:

    02CB 33FA FFD4 331D 00AF 3304 00CA 33FB FFD3 331D 00AF 3303

    At the beginning of each data byte is 0 x 33 or 0 x 34, followed by more than 3 bytes. As you can see he has not finished the last byte of data (3303) the rest of the data is contained in the beginning of the next package that would be:

    02CB 33FA FFD4 331D 00AF 3304 00CA 34FB FFD3 00AF 3305 331D

    Thus, the finished data would be 3303 02CB. I'm having a lot of trouble with between them each data packet and adding on a string of incomplete data.

    It's an interesting way to use the input of the splitter in the chain of worksheet to the array function.

    The images below show a simple approach, I think that's what you want.  The part of the code not shown is a shift register.  The string from the left is connected to the shift register terminal to the left.  The first string to right connects to terminal of shift register to the right. The shift register is initialized with an empty string.  The lowest string on the right connects to a terminal autoindexing and creates the table shown in the results.  The constant related to the terminal Regular Expression is defined in "Hex" mode  Read the help for the match pattern for more information on how it works.  Rather than the table would connect you your function to queue for the indicator of substring matching.

    This code replaces all in the structure of your business.

    Lynn

  • REGEXP: String normalization

    Hi all

    Is it possible to normalize a string using a REGEXP to follow this rule:


    1. If the string begins with BLOCO or LOTE channels, keep it in the beginning of the string.
    2. keep the first channel number
    3 - If the first number is followed (after a space) that a single character include the number
    4 - If the first number is concatenated characters keep the whole word.



    Examples of data with examples:

    WITH t AS
    (SELECT 'LOTE 1' input_string,
             'LOTE 1' output_string
        FROM dual
      UNION ALL
      SELECT 'BLABLA 1' input_string,
             '1' output_string
        FROM dual
      UNION ALL
      SELECT 'BLOCO 11 A 3' input_string,
             'BLOCO 11A' output_string
        FROM dual
      UNION ALL
      SELECT 'BLOCO 3A' input_string,
             'BLOCO 3A' output_string
        FROM dual
      UNION ALL
      SELECT '4 A' input_string,
             '4A' output_string
        FROM dual
      UNION ALL
      SELECT '5 AA' input_string,
             '5' output_string
        FROM dual
      UNION ALL
      SELECT 'LOTE 6 RC' input_string,
             'LOTE 6' output_string
        FROM dual
      UNION ALL
      SELECT 'LOTE 7-A' input_string,
             'LOTE 7-A' output_string
        FROM dual)
    SELECT *
      FROM t;
    
    

    Kind regards

    Manel

    Post edited by: Manuel Vidigal Typo in "BLOCO 11 A 3"output ".

    Then

    Select

    input_string

    output_string

    regexp_substr)

    regexp_replace (input_string, ' (\d) ([^ [: digit:]] (| $))', "\1\2", 1, 1)

    ,'(^ BLOCO. | ^Lote) [^ [: digit:]] * \d [^] * | \d[^] * "

    ) o

    t

    Some explanantion:

    First in the regexp_replace replace us (I modified it) the first occurrence of a followed by a space and a number digt not) with numbers and his successor non-chiffres.

    And then from there we take if the string begins with BLOCO or LOTE everything from the beginning selection until the first digit and after this figure in the next space or at the end if there is no following space.

    If there is no key words at the beginning only since the first digit comes from the same way as above.

  • ActionScript 3 String Match() help

    Hello

    I have a several of the hyperlinks on a Web page and I only need to store a few who have a certain rhythm in a variable/table.

    I discovered that you can do this with the match() function. I loaded the container on the Web page in a chain, so I'm just using the MATCH function to try to find the model. The problem is, I'm not bad with reg expressions.

    The hyperlinks I want to catch are written as follows: < a href = "/somename/sameForAllFilesfile.sz" > link < /a > Some

    I only need to store the content between the href =' and ' >.» The file 'sameForAllFiles' is what is common for all files and what I'm trying to use the EQUIV, but I can't get the right expression. Can someone write a basic example of code that I could use?

    Thank you!

    If you use the 'match' method, so that:

    var string: String = "blablabla\

    Some link blablabla\

    Some Link2.

    Some Link3';

    //

    var directoryTemplate:String = ' / sameForAllFiles / ';

    //

    [var regSource:String = '<><>] + href = "[^" "] +" + directoryTemplate + "[^" "] +" [^<>] * > ';

    var reg: RegExp = new RegExp (regSource, 'g');

    //

    trace (String.match (REG));

    Result:

    ,,

  • String replaceAll() help

        //kill characters method used to remove unwanted characters
        //from strings, takes in unedited string, returns formatted string
        private String killChars(String fixThis )
        {
            return fixThis.replaceAll("\\W", "");
        }//end
    Hey guys and girls.

    I have this method in one of my applications and I do not exactly get the results I want. Is there a way to manipulate the replaceAll function arguments so that it will replace all non alphanumeric except for spaces? In fact, I want to keep white space.

    Thank you

    Kyle

    I think you can use "[^ \\s\\w]", which is anything other than whitespace or Word because. try it, see if it does what it takes.

  • Adding string Please HELP!

    Hello

    I need to know that action script uses to add channels to the formatting variables.

    For example, I have this code

    public void addString(str1:String):void

    {

    For (i: int = 0; i < data.length; i ++)

    {

    trace (data [i] .str1)

    }

    }

    of course, this does not work but what is the format for the string to properly attached at the end of the data [i]. ??

    trace (data [i]. {} str1});<---something like="" this?----="">

    To get a property defined by a writing value string variable:

    data [i] [str1]

    data [i] are an object of your collection and data [i] [str1] are the property of "str1" of this object.

  • need help with a regexp

    I would like to extract all the digits in a string delimited by a point, possibly using string.split(). My abilities in writing expressions good regulare is simply not there, any help would be much appreciated
    String regexp = "";
    String s="this should result in nothing. Nothing at all."; 
    s.split(regexp); //result: {}
    s="50"; 
    s.split(regexp); //result: {"50"} 
    s="11.5000.25"; 
    s.split(regexp); //result: {"11","5000","25"}
    s="50x"; 
    s.split(regexp); //result: {}
    s="11.500x.25";
    s.split(regexp); //result: {}

    The best I can do is

          String[] splitS = s.matches("(?:\\d+\\.)*\\d+")? s.split("\\."):new String[0];
    
  • Determine if a string contains an expression of certain

    Hi all

    I feel that there should be a simple way to do this, but I was not able to understand after browsing these forums, the help of LV and Google.

    I just want to get in a string and returns true if it is false if is not to determine if it contains a certain expression. I understand there are regular expression screw, as model of matching and Match Regex, but those who return substrings; I want just a Boolean value returned. I could use the VI regular expression corresponds to analyze output strings to determine if it finds a match and returns a Boolean value from there, but I feel like there is a way better and simpler I forget.

    In the subpalette of 'additional string functions' I see there first Match string and string of true/false game, but using the first Match string seems like it would complicate what I try to do, and I don't yet know what game true/false String; detailed help is always confusing.

    Thanks for any help!

    There are simple ways. Read the help associated with search string functions! Each of them returns the offset of the found string. It is - 1 if it is not found. A simple function to Less Than Zero can be connected to this to return a Boolean value. Another way is to compare the substring returned by the function of empty string.

  • concatenate a string and a sequence number

    Hey guys,.

    I use jdeveloper Studio Edition Version 11.1.2.1.0.

    I would attribute a sequence that I have attached a string to my PK as a AP2013081000 attribute.

    Could someone help how the above application can be achieved in the adf?

    Here are the trigger and how could I use it to record in my attribute?

    create or replace

    LEARNER_TRG RELAXATION

    INSERT BEFORE ON THE LEARNER

    FOR EACH LINE

    BEGIN

    < < COLUMN_SEQUENCES > >

    BEGIN

    IF: NEW. STUDENTNO IS NULL OR: NEW. STUDENTNO < 0 THEN

    SELECT TO_CHAR ("AP": to_char (sysdate, 'YYYYMM') |) LEARNER_SEQ. NEXTVAL) IN: NEW. STUDENTNO FROM DUAL;

    END IF;

    END COLUMN_SEQUENCES;

    END;

    I used the DBSequence data type

    only for the

    LEARNER_TRG RELAXATION

    INSERT BEFORE ON THE LEARNER

    FOR EACH LINE

    BEGIN

    < < COLUMN_SEQUENCES > >

    BEGIN

    IF: NEW. STUDENTNO IS NULL OR: NEW. STUDENTNO < 0 THEN

    SELECT to_char (sysdate, 'YYYYMM') | LEARNER_SEQ. NEXTVAL INTO: NEW. STUDENTNO FROM DUAL;

    END IF;

    END COLUMN_SEQUENCES;

    END;

    Kind regards

    Steve

    You should be able to use the groovy for that approach. In this case you needn't pl/sql. Binary decompilation ADF: Groovy expression for assignment DB Sequence value for an attribute of type String should help you get started.

    Timo

  • Strange error Please Help

    Hi friends


    the query
    SELECT nvl(SUM(NET_WEIGHT_FARMER),0) FROM WEIGHT_SLIP where weight_out > 0 and weight_out_date between to_date(trunc(sysdate - 1) || ' 04:00:00','dd-mon-yy hh24:mi:ss') and to_date(trunc(sysdate) || ' 04:00:00','dd-mon-yy hh24:mi:ss')
    This query runs perfectly my php code using oci_execute but the query even when it is used in VB6 returns the following error

    OIC-01861: literal does not match the format string

    Kindly help


    Concerning
    Parikshit

    Your conversion rate of date is all wrong...

     to_date(trunc(sysdate - 1) || ' 04:00:00','dd-mon-yy hh24:mi:ss')
    

    This:

    trunc(sysdate - 1)
    

    Returns a DATE data type

    This:

    trunc(sysdate - 1) || ' 04:00:00'
    

    attempt to concatenate a string of VARCHAR2 to the DATE dataype, causing the DATE to be implicitly converted to a string according to your local NLS_DATE_FORMAT settings (* which may differ between environments), giving you a potentially unknown format in your chain.

    You then take this string of unknown format potentially and:

     to_date(trunc(sysdate - 1) || ' 04:00:00','dd-mon-yy hh24:mi:ss')
    

    ... to tell things to convert it to a DATE data type based on the format "LUN-JJ-AA hh24:mi:ss' which can be or not what the string is.

    I think you just want something like:

    trunc(sysdate-1)+(4/24)
    

    which truncates the value of DATE for the next day (i.e. to reset the time to 00:00:00, then add 4 hours to it.

  • CSV to lines question please

    Hello

    I have a csv list, but I want the csv in rows, something like that - any help is greatly appreciated.

    Oracle Database 11 g Enterprise Edition Release 11.2.0.2.0 - 64 bit Production

    WITH t

    AS (SELECT "a" id, 1, 2, 3, 4' ordr FROM DUAL)

    UNION

    ID to SELECT 'b', ' 1, 2, 3, 4, 5' ordr FROM DUAL

    UNION

    SELECT 'c' id, 7, 8' ordr FROM DUAL)

    SELECT *.

    T

    want to the result like this-

    ID - ordr

    a 1

    a 2

    a 3

    a 4

    b 1

    b 2

    b 3

    b 4

    b 5

    c 7

    c 8

    Thank you very much.

    Here's how:

    Notes on the Oracle: split delimited by a comma the way of RegExp string, second part

    SQL > WITH t AS (SELECT 'a' id, ordr ' 1, 2, 3, 4' UNION DOUBLE)

    2 id SELECT 'b', ordr ' 1, 2, 3, 4, 5' OF the UNION DOUBLE

    3. SELECT 'c' id, 7, 8' ordr FROM DUAL)

    4. select id

    5, regexp_substr (ordr, ' [^,] +', 1, rn) split

    6 t

    7 cross join (select rownum rn

    8 in (select max (length (regexp_replace (ordr, ' [^,] +'))) + 1 mx)

    9                      from   t

    10                    )

    11. connect by level<=>

    12             )

    where the 13 regexp_substr (ordr, ' [^,] +', 1, rn) is not null

    14 order of 1,2;

    I SHARED

    - ---------

    a 1

    a 2

    a 3

    a 4

    b 1

    b 2

    b 3

    b 4

    b 5

    c 7

    c 8

    11 selected lines.

  • Validate numbers and characters in a form field.

    Hi all

    I have created a form and in it, there are e-mail and phone number fields.

    I found http://forums.adobe.com/thread/857974

    to be really useful to help me validate my email field.

    Then I tried to tweak for the phone number field I need to allow only characters 1234567890 +)

    As you can see, the number of his just and + (). How to restrict the field to only accept characters?

    I tried but it failed:

    Custom text field validation script

    (function () {}

    var val = String (event.target.value);

    Do nothing if the field is empty

    If (! val) return;

    If the value is not a phone number valid...

    If (! val.match (/ \ +?)) [ 0-9\(\)]*/)) {

    .. .that the user knows that the value is not a valid phone number...

    App.Alert ("Please enter a phone number, for example + 012 (3) 123123123", 3 ");

    .. .and set the focus on this field

    event.target.setFocus ();

    }

    })();

    But it does not work. Sigh.

    I have 0 training in computer language (I am a biologist, and this is a form for doctors to fill with data of patients) and would appreciate your help in getting the work phone field validation.

    Thank you!

    Try this script:

    function validate (telephone) {}

    var regex = /^(\+) ((?: [0-9]?) 6.14 {[0-9]) $/;

    If (regex.test (phone)) {}

    Valid international phone number

    return the RegExp. $1 + "" + RegExp. $2;

    } else {}

    Invalid international phone number

    Return ' ';

    }

    }

    If (event.value! = "") {}

    Event.Value = validate (event.value);

    If (event.value == "") {}

    App.Alert ("Please enter a valid + 1 international phone 12(3) 123123 number\n (12312)") ", 1, 0);

    Event.RC = false;

    }

    } / / end of non-null field value

    Note it is a validation script and runs only when you leave a field. If you want to check hits then you will need to use the custom keystroke script and you can use this code as a starting point, but you will need change the format RegExp string to test every keystroke as it is typed.

  • Read and write in a PARAM. CMI file?

    Hello

    I have a problem with the reading and writing of a PARAM. CMI file. If I remove the "Section" block at the top and move the first element to the top, I can read very well but I can't get past the sections.

    Section ex: "[Core]" if I delete that and everything move upwards no problemo. Any help would be appreciated.

    Yes. Oops. It was the air code. You would use URLLoader and URLRequest instead of FileStream and file. My bad. For example, if you have done the URLRequest thing and got your file in a first function URLLoader I gave you become:

    private void loadCMIFile(evt:Event):void {}

    var cmiLoader:URLLoader = evt.currentTarget as URLLoader;

    try {}

    parseCMI (cmiLoader.data);

    } catch (err: error) {}

    trace (err.name, "\rUnable to parse the selected file." + err.message);

    }

    var lessonStatus:String = "Lesson_Status."

    trace (CMI [lessonStatus]);

    }

    Just parsing the text, we can make an object or an XML in flash that contains the data in a readable way, but if you want to rebuild the IJC to Flash file so you will need to know what these headers. I mean if there is no information and they are not text, you will need to know the number of bytes that they are and then put aside in a ByteArray so that you can transfer them on your later output file. Or you need to find the specifications of file for them - they could be full of location bytes or ID tags or who knows.

    Assuming that we have to fear is the analysis, I would like to make a suggestion. Maybe you want your data to a XML in Flash:

    private var cmiXML:XML =

    ...

    ...

    To save time to look for keywords, you can configure a set of vectors that contain

    private const cmiCore:Vector. = new ["Student_ID', 'Student_Name',"Output_File"... etc.];

    private const cmiCoreVendor:Vector. = new ["CoursePath"];

    private const cmiEvaluation:Vector. = new ["Course_ID', 'Comments_File', 'Objectives_Status_File'];

    etc...

    Then you can read like this:

    private void parseCMI(string:String):void {}

    analyze the main

    for (var i: int = 0; i< cmicore.length;="" i++="">

    var regExp:RegExp = new RegExp (cmiCore [i] + "=");

    If (regExp.test (string) {}

    cmiXML.core.child (cmiCore [i]) = extract (string, regExp);

    }

    ]

    }

    private void extract(str:String,_re:RegExp):String {}

    var value: String = str.substr (str.search (re));                    makes a string that starts after the "equal" sign

    value = value.substring(0,value.search(/[\r\n]/);           cut the string at the first jump of line or return transport

    Returns the value;

    }

  • RS - 232 ascii data analysis

    I have a need to compare the incoming of RS-232 ascii data tables or tables for accuracy. I can generate data using the RS-232 module, but I don't know what to do with incoming data. Orders and incoming data vary. The data is a string variable. Because it varies with the command that I don't know how to compare it to a table of choice etc.

    JLW

    There is an error in my formula... it is based on a variable that is not really defined.

    Thus,.

    strval (substr (${STR_3}, strind (${STR_3}, "current =" "") + 10, strind (${STR_3}, "(") - strind (${STR_3}, "current =" "") + 10 ")))

    the syntax is:

    substr (String, start, length)

    STRIND (String, search string) - gives you a number that is the beginning of the search string, must be added in advance at the end of the search string

    strval (string) - transforms a string in a number

    So, to deconstruct the formula

    Browse to the location of the number, in this case, it is immediately after "current =", so look for this string and add 10 to advance beyond it. "

    Find the location of the next bracket, look for "().

    Calculate the length of the number by subtracting the position of the bracket of the position of the beginning of the number

    current XXXXXXX = 42.0 (ampsx10)

    ^              ^      ^

    A             B     C

    East strind (${STR_3}, "current =" "")

    B = A + 10 or strind (${STR_3}, "current =" "") + 10

    C = strind (${STR_3} "(" ")")

    length b = C - B or C - 10 A +.

    So, using this notation, the above formula is

    STRVAL (SUBSTR (STRING, A + 10, C - A + 10))

Maybe you are looking for