Model maching class of regular Expression to validate the alphanumeric string

Hello
MY version of DB is Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production 64-bit

I wanted to use the model maching given by oracle classes to check whether a given input string is alphanumeric.

Documentation Oracle 10 g said about classes like [: digit:], [: alnum:] and many others.

http://www.DBA-Oracle.com/t_regular_expressions.htm

However these classes seems not work with my version of DB.

Can someone tell me the DB version in which these classes work?

Here is the code I use to validate an input string.
SQL> CREATE OR REPLACE FUNCTION fn_is_alphanumeric
  2  (
  3     pi_value             IN       VARCHAR2
  4  )
  5  RETURN VARCHAR2
  6  IS
  7     lv_length   NUMBER;
  8  BEGIN
  9     lv_length := length(pi_value);
 10     IF ( REGEXP_LIKE(pi_value,'[:alnum:]{'||lv_length||'}')) THEN
 11        RETURN 'TRUE';
 12     ELSE
 13        RETURN 'FALSE';
 14     END IF;
 15  END fn_is_alphanumeric;
 16  /

Function created.

SQL> 
SQL> 
SQL> SELECT fn_is_alphanumeric('abc123') alpha FROM DUAL;

ALPHA
--------------------------------------------------------------------------------
FALSE

SQL> 
SQL> 
SQL> CREATE OR REPLACE FUNCTION fn_is_alphanumeric
  2  (
  3     pi_value             IN       VARCHAR2
  4  )
  5  RETURN VARCHAR2
  6  IS
  7     lv_length   NUMBER;
  8  BEGIN
  9     lv_length := length(pi_value);
 10     IF ( REGEXP_LIKE(pi_value,'[A-z0-9]{'||lv_length||'}')) THEN
 11        RETURN 'TRUE';
 12     ELSE
 13        RETURN 'FALSE';
 14     END IF;
 15  END fn_is_alphanumeric;
 16  /

Function created.

SQL> SELECT fn_is_alphanumeric('abc123') alpha FROM DUAL;

ALPHA
--------------------------------------------------------------------------------
TRUE

Arun Kr Gupta says:
Hi knani
I need to check whether the input string is alphanumeric.

That's why "ABC" all entries as '1234', '123ABc', must return true.

Also can the alphanumeric string contains characters that are available on the keyboard which can be seized of it.

Concerning
Arun

Published by: Arun Gupta of Kr on October 18, 2010 11:46

I just read your requirement "all printable characters.

Try:

select regexp_like('string','^[[:print:]]$') from dual

to get only the records that have only printable characters.

Tags: Database

Similar Questions

  • 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

  • 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});

  • 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.

  • 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 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.

  • 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 [.-/]

  • Regular expression in APEX

    Hi all!

    I am in need of a simple regular Expression for a validation of the APEX

    I need a regular expression that validates the content of a variable is in the following form: 2 052 001

    My validation is:

    ^ ([[: digit:]] + |) [[: digit:]] {1,3} (?: \,[[:digit:]]{3})+)$ but the validation does not work, but it works correctly javascript)

    Help me!!

    Any ideas?

    Thank you!

    I deleted the expression (?: \) and worked properly.

    ^ ([[: digit:]] + |) [[: digit:]] {1,3} (, [[:digit:]]{3}) +]]) $

    Thank you!!

  • Regular expression help please. (extraction of a subset of the string between two markers)

    I haven't used regular expressions before, and I can't find a regular expression to extract a subset of the string between two markers.

    The chain;

    Stuff of header I want
    Stuff of header I want
    Stuff of header I want

    Stuff of header I want
    Stuff of header I want
    Stuff of header I want

    6 ERRORS
                         
    Info I want to line 1
    Info I want line 2
    Info I want line 3
    Info I want to line 4
    Info I want to line 5
    Info I want line 6
    END_ERRORS

    From the string above (it is read from a text file), I try to extract the subset of string between ERRORS 6 and END_ERRORS. The number of errors (6 in this case) can be any number from 1 to 32, and the number of lines I want to extract will correspond with this number. I can provide this number of a caller VI if necessary.

    My current solution, which works, but is not very elegant;

    (1) using Match Regular Expression for the return of the string after you have synchronized the 6 ERRORS

    (2) uses the Regular Expression matches to return all characters before game END_ERRORS of the string returned by (1)

    Is there a way this can be accomplished using 1 Regular Expression Match? If so someone could suggest how, as well as an explanation of the work of the given regular expression.

    Thank you very much

    Alan

    I used a character class to catch any word or whitespace characters.  This put inside parentheses a substring matching the criteria that you can get by developing the node for regular expression matching.  The \d matches the numbers and the two * s repetition of the previous term.  So, \d* will find the '6', as well as "123456".

  • Analyze the Mac address with the regular expression matching

    Hello world

    I have a problem with the function of regular expression matching,

    I try to analyse the response both a query arp - a 192.168.0.15 to retrieve the MAC address of the remote IP address, I used the following regular expression: ^ ([0-9a-fA-F]{2}[:-]){5}([0-9a-fA-F]{2})$

    I wonder why should I do a subset of the first string to extract only the part of the MAC address. The regular Expression function is not able to recognize the regular expression directly in the middle of a string?

    I only works when I extracted the subset of tring right as in the picture below.

    Thanks for your replies.

    Get rid of the "^" at the beginning of your regular expression. You are ordering him to find the model at the beginning of the string.

  • VALIDATION OF EMAIL USING REGULAR EXPRESSIONS

    Hi all

    I'm new to regular expressions and trying to learn about them.
    As practice I am developing a query to filter identifying them invalid e-mail, for example: -.
      <some-name>.<some-name1>@gmail.com - VALID
      <some-name>_<some-name1>@gmail.com - VALID
      <some-name>@<some-name1>@gmail.com - INVALID 
    
     
    Let's say that the name column is EMAIL_ID
    So I have the expression to validate the end of the e-mail as follows
       select email from <table-name> where REGEXP_LIKE (EMAIL,'.com$')
    But I don't know (it is even possible to wheter) to filter the third mail electronic id
    provided that there * 2 @*.

    Any help in this regard would be welcome

    This is what you need

    select email from 
    where REGEXP_LIKE (EMAIL,'^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$')
    
    SQL> WITH t1 AS (SELECT '[email protected]' email FROM DUAL
      2              UNION
      3              SELECT '[email protected]' email FROM DUAL
      4              UNION
      5              SELECT 'test3@[email protected]' email FROM DUAL)
      6  SELECT email
      7    FROM t1
      8   WHERE REGEXP_LIKE (EMAIL,
      9                      '^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$');
    
    EMAIL
    ---------------------
    [email protected]
    [email protected]
    
    SQL>
    
  • Help... Regular expression for characters [special] /: ^ &amp; * () @# $

    Regular expression to parse the string in square brackets:
    I am trying to parse a string in square brackets, but as [] are special characters used in regular expressions to start a character class, I want to remove its special meaning. This regular expression **_user=[a-zA-Z]*@[a-zA-Z]{2}+.abc.com_** works for the analysis of [email protected]* but I want to analyze _user = [[email protected]] _ *, I use the term regular *user=\[[a-zA-Z]*@[a-zA-Z]{2}+.abc.com\]*_* but is in error because it makes special sense of character class. I tried to use \ backslash before *------[]] * but it not working giving error * "INVALID ESCAPE SEQUENCE."

    [JAVA CODE: user = "user=\[[a-zA-Z]*@[a-zA-Z]{2}+.abc.com\"];
    Pat pattern is Pattern.compile (user);.
    Carpet to match = pat.matcher ("2011-03-11 02:08:44, 653: User = [[email protected]], Doing report: account.server.regprocmemunix.daily");
    If (mat.find ()) {}
    User1 = mat.group ();
    }
    This room code gives error _ _ "SEQUENCE EXHAUST" INVALID and throw a PatternSyntaxException*.

    Please help me parse the string within large brackets [].

    You realize that, although ' [' is a special character in a regular expression, ' \' is a special character in Java, right?] You also need to escape to the ' \'.

    So, if you want to use ' [' in your regular expression, you must use something in the sense of]

    \\[
    

    Published by: almightywiz on April 25, 2011 14:05

    DOH... too slow...

  • problem with the validation type: regular expression

    Hi all
    I have a text field element call p40_opt
    in the past, this element could accept only the values 1-9
    I made a posting type: regular expression
    1 validation expression:
    p40_opt

    2 validation expression:
    [1-9]

    works very well.

    Today, I wanted to add an option that p40_opt can also contains the value: 10
    so I changed the range [1-10].

    and now, it's not good because if I choose another option plus 1 and 10 to Ant

    he do the validation.

    what I'm missing here?
    Thanks in advance

    Under the direction of: naama on August 6, 2009 01:31

    The forum software has mutilated regular expressions in your message. You should edit, wrapping up the regular expressions in.

     tags so they are properly displayed.
    

    ^ [1-9] {1} $. ^ $ 10

    would be one regular expression that performs the required validation, however a regular expression doesn't appear to be the most straightforward way to validate such a range of values. A SQL or PL/SQL validation would be clearer, using the expression:
    

    : p40_opt between 1 and 10

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
    
  • Regular expression for?

    What would be the regular expression to extract the "LEDsOnFront" of the string "FELIX-TestModules-LEDsOnFront - VIT.vit" (price not included)?

    Looking for whatever text is between FELIX-TestModules - and - VIT.vit?  If so, try using the Scan of string with a 'PUME-TestModules-%[^-]-VIT.vit' format specifier

  • 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

Maybe you are looking for