How to use regexp_like to validate a string

Hi all

We want to validate a column value, which must be of 'a - z' and ' / '.
We try to use regexp_like for this, but it does not work.

By example, "abcd/efgh" is valid, and ' ab.cd / ef - gh' is not valid.

SELECT 'PASS '.
OF THE DOUBLE
WHERE regexp_like('abcd/efgh','[a-z]|[]')

We hope that the result is PASS, and the result is PASS, too.

SELECT 'PASS '.
OF THE DOUBLE
WHERE regexp_like('ab.cd/ef-gh','[a-z]|[]')

We hope that the result is NOT PASS, but the result is always PASS.?!

How can we use regexp_like to validate a string with specific characters?

Any suggestion will be appreciated.

Best regards
Zhxiang

Hello

Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
Connected as hr

SQL>
SQL> with data as(
  2  select 'abcd/efgh' as d from dual union all
  3  select 'ab.cd/ef-gh' as d from dual)
  4  select * from data where regexp_like(d, '^[a-z/]+$');

D
-----------
abcd/efgh

SQL> 

Kind regards

Tags: Database

Similar Questions

  • How to use EmailValidator to validate a simple string instead of TextInput

    Hello

    I would use EmailValidator for validate if a string is a valid email address. But I got an exception when I tried to put the source chain.

    var tmp:string = [email protected] ;

    var emailVal:EmailValidator = new EmailValidator();

    emailVal.source = tmp;

    I know that we usually do

    emailVal.source = new TextInput()

    emailVal.property = "text".

    But here, I just want to validate a string. How can I do?

    Kind regards

    Haibin

    Use the validate() method, which returns the validationresultevent; now, you can check the property type of the event.

    Code:

    var tmp:String = "[email protected]";

    var emailVal:EmailValidator = new EmailValidator();
    var vr:ValidationResultEvent = emailVal.validate (tmp);
    if(VR.type == ValidationResultEvent.valid)
    ; It is valid
    on the other
    ; It is not valid

  • How to use a value of a string variable as a sound (like an audio file link name) class?

    Hello

    I need to use the value of a string variable as a binding name of any sound in the library, I have this code:

    var SoundArray:Array = new Array;
    SoundArray [0] = "S1";
    SoundArray [1] = 'S2 ';
    SoundArray [2] = "S3".
    var MySound = new SoundArray [0];
    B1.addEventListener (MouseEvent.Click, PlaySound);
    function PlaySound(event:MouseEvent) {}
    MySound.play (0,0);
    }

    where S1, S2, S3 is the name of the class in the name of link for 3 audio files in the library.

    I get this error for the line of code:

    TypeError: Error #1007: instantiation attempted on a non-constructeur.
    at Untitled_fla::MainTimeline/frame1()

    Sorry, sorry, sorry
    the error was not from your code, I had fixed and it is the right code:

    var soundClass = flash.utils.getDefinitionByName (this.) V_Source) as class;
    var currentlyPlayingSound = new soundClass();
    var currentSoundChannel = new Object;
    MovieClip (parent) [this. V_Button] .addEventListener (MouseEvent.Click, PlaySound);
    function PlaySound(event:MouseEvent) {}
    currentSoundChannel = currentlyPlayingSound.play ();
    }

    Thank you very much

  • How to use textfiled to display a string that some characters are integrate the other font not support

    Hello world

    I try to use fonts embed on a textfield, however, embed police can only support limit glyphscharacter.

    So I was thinking is - it possible that if the police understand the character, I use this font, if not understand, I use the system default font

    as the text function on http://picmonkey.com

    If I want to use embed fonts to textfield, I need to set textFiled.embedFonts = true

    However, if I did that, the characters not included in font is not displayed, even I change textformat.font = "_without"

    So how to solve this problem?

    What did picmonkey do?

    use textFiled.embedFonts = false

  • correspondence of model using regexp_like

    Hi, I'm looking to match the following string using regexp_like

    example of string is 86/HCFD/204010/041/PT '

    I tried to use it but it looks like I'm wrong somewhere, somebody can suggest me how to go to this topic

    Select 86/HCFD/204010/041/PT ' double

    where REGEXP_LIKE (86/HCFD/204010/041/PT ',' [^ [[: digit:] {1,2}] + / [[: alpha:] {4,8}] + / ']);

    then...

    WITH the DATA (str) AS (SELECT 86/HCFD/204010/041 / PT ' DOUBLE)

    Select str

    FROM THE DATA

    WHERE regexp_like (str, ' ^ [[: digit:]] {2} / [[: alpha:]] {4} / [[: digit:]] {6} / [[: digit:]] {3} / [[: alpha:]] {2} $');

    HTH

  • How REGEXP_REPLACE used to replace the part of the string?

    Hello

    How can I replace the portion of string as follows, I want to replace the space as by ' - '.

    SELECT
    REGEXP_REPLACE (superior ("' Laura bought stuff from 2000 USD on 12 September 2012 to KL and kl left on September 20, 2012"),)
    ' [0-9] {1,2} [^ 0-9](JAN|) FEB | MAR | APR | JUN | JUL | AUG | MS | OCT | NOV | DEC) [^ 0-9] [0-9] {4}',
    (','-') "REGEXP_REPLACE.
    FROM DUAL;

    the output will be like this

    Laura bought of the stuff of 2000 USD on 12-Sep-2012 of KL and kl left on 20-Sep-2012

    concerning

    Something like that?

    SELECT
    REGEXP_REPLACE('Daivd bought stuff by 2000 USD on 12 Sep 2012 from KL and left kl on 20 Sep 2012',
    '([0-9]{1,2}) (JAN|FEB|MAR|APR|JUN|JUL|AUG|SEP|OCT|NOV|DEC) ([0-9]{4})',
    '\1-\2-\3',1,0,'i') "REGEXP_REPLACE"
    FROM DUAL;
    

    Explanation:

    You group the parts of the date de-construct with (additional).
    You can use expressions, backreference \1 \2 \3 and add '-' between \1-\2-\3 signs.

    You should not user upper ('...') in the first parameter. If you cannot recover the original state of the letters.
    If you want to case-insensitive matching you should use 'I' in the last parameter of regexp_replace.

    http://docs.Oracle.com/CD/B19306_01/server.102/b14200/functions130.htm

    Published by: hm on 25.09.2012 00:38

  • How can I use the sequence of the string "\u00e5" in myfile.txt converted unic

    How can I use the sequence of the string "\u00e5" in myfile.txt converted to unicode in my application?

    I have a text file, MyFile.txt, with some sequences represented unicode:
    \u00e5
    \u00e4
    \u00f6
    etc.

    This is the file contains unicode, not the character it represents: a, a and o.
    I get the sequence of the file and save it to a vector. When I tried to use it on a JButton, I see the "\u00e5" string and not the character that I assumed.

     
            read file codes ...
            ...
         Vector<String> glyphVector = readGlyphIndex.getUnicodeFiles();     // to retrieve the vector with unicode sequence and save it to glyphVector
         String unicode = glyphVector.get(0);     //get the first unicode sequence
            System.out.println(unicode);    //displays \u00e5 and not å in the console.
         jButton.setText(unicode);   //jButton is a JButton and it shows the string \00e5 and not the character å
            ...
    The question is how to convert the sequence of string to be a unicode escape in the code?

    In order to make it clear:
    //from
    jButton.setText("\\u00e5");
    //to
    jButton.setText("\u00e5");
    Thanks in advance!

    Dragonfly
    String s = Character.toString((char) unicodeInInt);
    

    Strictly speaking, if unicodeInInt is a Unicode code point (for example, it can be greater than 0xFFFF) then the correct code would be this:

    String s = new String(Character.toChars(unicodeInInt));
    

    However, since the "\u" notation allows only 4 hexadecimal digits (and need to 0xFFFF code points > Unicode represented by their UTF-16 encoding), the code above is not enough for this particular case.

  • How to recover data using regexp_like

    Hi all

    I have to use the function regexp_like on our books, please let me know how to use in this situation.below is sample data.
     id        Name          department
     1         A                3~2~1
     2         B                14~10~3
     3         C                 22~7~6
     4         D                 4~5~9
    If I pass the Department number 2 result shows id 1
    14-> id 2 are coming.
    22-> id 3.

    Kind regards
    Rajasekhar

    Published by: SuNRiZz68 on April 27, 2009 07:30

    Hello
    Just add: WHERE INSTR ('~ ' | Department |) '~', '~' || : by | '~') > 0;

    Cordially Salim

    SQL> var par varchar2(20)
    SQL> exec :par:='1';
    
    Procédure PL/SQL terminée avec succès.
    
    SQL> WITH t AS
      2       (SELECT 1 ID, 'A' NAME, '3~2~1' department
      3          FROM DUAL
      4        UNION ALL
      5        SELECT 2, 'B', '14~10~3'
      6          FROM DUAL
      7        UNION ALL
      8        SELECT 3, 'C', '22~7~6'
      9          FROM DUAL
     10        UNION ALL
     11        SELECT 4, 'D', '4~5~9'
     12          FROM DUAL)
     13  SELECT *
     14    FROM t
     15   WHERE INSTR ('~' || department || '~', '~' || :par || '~') > 0;
    
            ID N DEPARTM
    ---------- - -------
             1 A 3~2~1
    
    SQL> exec :par:='22'
    
    Procédure PL/SQL terminée avec succès.
    
    SQL> WITH t AS
      2       (SELECT 1 ID, 'A' NAME, '3~2~1' department
      3          FROM DUAL
      4        UNION ALL
      5        SELECT 2, 'B', '14~10~3'
      6          FROM DUAL
      7        UNION ALL
      8        SELECT 3, 'C', '22~7~6'
      9          FROM DUAL
     10        UNION ALL
     11        SELECT 4, 'D', '4~5~9'
     12          FROM DUAL)
     13  SELECT *
     14    FROM t
     15   WHERE INSTR ('~' || department || '~', '~' || :par || '~') > 0;
    
            ID N DEPARTM
    ---------- - -------
             3 C 22~7~6
    
    SQL> 
    
  • How to use a script to validate the same field with different addresses in different pages?

    I have a script that is applied to a field 'email '.

    The script asks to check the address, if it is not well written.

    But this field is present in many pages for different guests filling in this information.

    How can I adapt this script? (without changing the name of each field of each page and therefore to change the value in the script to a page that ...)

    function confirm_email_OnValidate (element)

    {

    Event.RC = confirm_email_Validate (Element, event.value);

    }

    function confirm_email_Validate (Element, newvalue)

    {

    If (newvalue.length < = 0)

    Returns true;

    Model = newvalue.replace (/ [a-zA-Z0-9] + ((\.| _ | \-) [a-zA-Z0-9] +) * @([a-zA-Z0-9] +(\.| \-))+[a-za-Z]{2,}/, «»);)

    If (Dummy.length! = 0)

    {

    InputError (element, 'Check this address');

    Returns false;

    }

    Returns true;

    }

    function confirm_email_Format (element)

    {

    Returns true;

    }

    You can use the eMailValidate built-in function to simplify this. For example, you can use the custom following validation script:

    if (event.value && !eMailValidate(event.value)) {
        app.alert("Check this address");
        event.rc = false;
    }
    

    It provides a validation better than the regular expression that you have demonstrated.

    Without knowing how you use the parameter of the element and the operation of the function InputError, it is difficult to offer something more.

  • How to choose the value of a string are numeric together and words of letters (for example, TEST)

    Hi all

    How to choose the value of a string are letters (for example, TEST) and all numeric...

    for example
    TEST 123456
    TEST 34567
    123456 ABCD
    1234 TEST
    TESTING 12345
    TEST [email protected]$
    YOUR T 123456

    I want the results of the query as below.
    TEST 123456
    TEST 34567

    And I tried to use regexp_like in this case but without success. See the code below.
    SELECT * FROM TABLE WHERE regexp_like (Description, ' [TEST] % & [[: digit:]] + $');

    How can I do this, please answer.

    Thank you

    WF

    If you want to return only the rows that contain the string 'TEST', followed by zero or more space characters, followed by one or more digits?

    How about this:

    SELECT *.

    FROM my_table

    WHERE REGEXP_LIKE(description,'^TEST\s*\d+$')

  • How to change the background color of string programmatically?

    How to change the background color of string programmatically?

    Are you talking about string indicator and control chain? If so, right-click on a control/indicator of string and select Create-> property Node-> text-> text-> BG Color colors. Change to write and a number of the color you want to use phone.

  • How to use 1-channel analog input for start/stop aquire sample second channel input analog?

    I have a little problem. I've just been programming in labview for 2 weeks.

    I'm trying to figure out how to use my channel of analog input on the USB-6009 case for start/stop (reference trigger and start) presented to the second analog input channel samples.

    I need the first analog input string to operate continuously and control sampling on the second.  When the second channel will start sampling program brings a new graph each time and saves it (I have all this that figure out).

    How can I configure the trigger so the lance program presented in for the second channel when the 1 channel reached above 2V (e.g.) and stop when it falls below 2V.

    I use a pressure force sensor on the first channel that gives me straight (up to) 5 V when it is pressed and nothing when it is not...

    Thank you.

    Grand... Thanks for the information!

    But can't I then make a 1 channel instead and wait until that meat of the max element value?

  • How to use the background rim start page: allowInvokeParams

    Hello

    How to use the element of the rim: background? what it is?

    1. To run javascript? openBISPushListener?
    2. Can you pass parameters between it and the content page?
    3. How to pass parameters between it and the content page?

    It defines a page will be loaded in the background when your application starts.  This page is intended to run any startup logic (for example starting listeners - Push is an excellent example) that your application may need to depend on, without any user interface.

    This background page is WITHOUT user interface.  Any attempt to interact with the user interface (for example change the DOM, calling alert() statements, etc.) will result in no action.  Nor will calls to redirect, since the background page does not interact with the pages of foregroud - if no query string.

    To answer your question - ' How do you pass parameters between it and the content page.  I suggest using a technique of storage like localStorage, WebDB, or same file offline.

  • How to use scheduleApplication - of is to wake up to 4 times a day

    I don't know how to use scheduleApplication and initialize them where there. Please see code below

    1. I have in hand. Is this correct, every time that the application runs that it will set the timetable, what's happening to the old?

    2 - I need my application to wake up to 4 times a day, how can I do that can I Schedule 4?

    3 - I put as that below to wake up at 17:03 (61380000), but he never did. The application did not run?

    result 4 Boolean is true, then I guess it's ok, but my request to wake up ever at 17:03, how to wake up several times a day?

    public class UserInterface extends UiApplication{
    
        public static void main(String[] agrs){
    
            ApplicationDescriptor desc = ApplicationDescriptor.currentApplicationDescriptor();      
    
            boolean result = ApplicationManager.getApplicationManager().scheduleApplication(desc, 61380000, false);
            System.out.println("Calling schedule is " + result );
            UserInterface theApp = new UserInterface();
            theApp.enterEventDispatcher();
    
        }
        public UserInterface() {
            pushScreen(new UserInterfaceScreen(this));
        }
    }
    

    Just to confirm that the application calls scheduleApplication, use the debugger and check what happens. Instead of 17:30, you can take the current time and add a few milliseconds and pick up the results of debugging. Wakingup several times, change the time before you quit the application.

  • SQL how to use a variable and use the result as a reference for the name of the table

    Hi all

    I have new in the declaration of Oracle, sorry in advance if something is easy for you all. BTW, I have this scenario:

    I have a table OL structured in this way:

    Date - it contains dates, for example 11/01/2015

    TableName - it contains strings, for example, OL1, OL2, OL3 and so on...

    Then I have a different table, the name of these tables are of the same name in the table of the OL, so I have table table, OL1, OL2, OL3 table and so on. The structure of these tables is the same. And Yes.

    table OL1

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

    ID LAST NAME FIRST NAME PHONE

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

    1 JOHN DOE 12345679

    2 PAUL 111111122 TIBBS

    table OL2

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

    ID LAST NAME FIRST NAME PHONE

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

    1 ANNA KRAIG (NULL)

    NATHAN FRESHMANN 111111133 2

    If the scenario is clear, I would like to retrieve the value (null), research in all the OL * tables by using the value of the OL table (tablename) max.

    If I'm going to do these simple steps, I got the result:

    Select max (TableName) OL

    the result will be OL2

    # I know not how to use the option set to avoid changing the table name in the sql statement all the time.

    set mytable = 'OL2.

    Select Name, family name

    of & mytable

    When the phone is null

    Any idea?

    Thank you very much in advance.

    Hello

    run immediately "select dt.log_id, obj.presentation_name, dl.begin_time

    bulk collect into v_result_set

    of ' | v_ol |' dt join internal ol_object obj on

    DT.object_type_id = obj.object_type_id

    inner join ol_chunk_log dl on

    DT.log_id = DL.log_id

    where dt.data_value is null';

    dbms_output.put_line (v_ol);

    end;

    Correct the code such as:

    run immediately "select dt.log_id, obj.presentation_name, dl.begin_time

    of ' | v_ol |' dt join internal ol_object obj on

    DT.object_type_id = obj.object_type_id

    inner join ol_chunk_log dl on

    DT.log_id = DL.log_id

    where dt.data_value is null' bulk collect into v_result_set;


    for i in v_result_set.first ... v_result_set. Last

    loop

    dbms_output.put_line ('LOG ID: ' | ) ( v_result_set.log_id (i)) ;

    dbms_output.put_line (' NAME CLOSELY: ' |) v_result_set.presentation_name (i));

    dbms_output.put_line (' START TIME: ' |) ( v_result_set.begin_time (i)) ;

    end loop;

    end;

    Kind regards.

Maybe you are looking for