Regular Expression TO validate column name

Hi All
I want to write a regular expression to validate column names.i.e enterted name should follow the valid column name convention
contain only A–Z, a–z, 0–9, _, $, and #
Please someone help me to do this.
Padma

Hi,
I would write it that way :SQL> with t as (
  2          select 'ABC$DEF1' cname from dual
  3          union all select 'ABC#DEF2' from dual
  4          union all select 'ABC_DEF3' from dual
  5          union all select 'ABC_#$x4' from dual
  6          union all select 'abc_def5' from dual
  7          union all select 'ABCDEFG%' from dual
  8          union all select 'ABC*DEFG' from dual
  9  )
10  select cname
11  from t
12  where not regexp_like(cname,'^[_#$[:alnum:]]+$') ;
CNAME
ABCDEFG%
ABC*DEFG
2 rows selected.You could also add some length condition in the regexp if your convention is supposed to enforce any.
Just my 2 cents :
DBMS_ASSERT.SIMPLE_SQL_NAME looks good +(I didn't know that package)+ but it would allow double quoted names with "unwanted" characters inside. Even if valid for the RDBMS maybe it's not ok regards to the OP's naming convention :SQL> l
  1  with t as (
  2     select '"Name with blank spaces"' cname from dual
  3     union all select '"Name with @ stuff"' from dual
  4     union all select '"Name with ~ stuff"' from dual
  5  )
  6  select DBMS_ASSERT.SIMPLE_SQL_NAME(cname) checked
  7* from t
SQL> /
CHECKED
"Name with blank spaces"
"Name with @ stuff"
"Name with ~ stuff"
3 rows selected.I guess this procedures lacks some option parameter to specify what is valid or not.
+(I hate to see column names with blank spaces in it)+
(^_^)
More seriously, if the point is to follow a chosen namig convention, I guess it would make more sense to have it explicitly written by the owner.
(You can't say how the DBMS_ASSERT package will evolve in futures RDBMS releases).

Similar Messages

  • How to validate column name in dynamic made sql?

    Oracle db, jdbc, web app with struts2/spring.
    Example table could be this:
    CREATE TABLE album
    album_id number(10)  not null,
      artist  varchar2(50) not null,
    title  varchar2(50) not null,
      released  DATE,  
      CONSTRAINT album_pk PRIMARY KEY (album_id)
    );In may app the user MAY search, MAY sort, and the result from an select might return 10.000 rows.
    The basic sql usually look like this.
    String sql = "select album_id, artist, title, released from album";Then in the html page the user can add search criteria for each column. Like type "iron maiden" in artist field, put "1982" in released field. And you all know what the exceptionally result should be from that :)
    Now I need to modify the sql a bit:
    if( artist search field contains stuff )
       sql = sql + " where nvl( artist,' ') like ?"
    }we try use prepared statements right? So we use ? as placeholders, and then add "iron maiden" into this statement later on.
    Nice, no big fuzz right, and pretty safe from sql injections i guess.
    But now I have to have an if/else for every single field in the table. Boring. In my app I got like 25 tables like this, with 20 columns minimum. Copy/Paste have never been so boring.
    I also might have to add "order by" with user selected columns and their order. I have to count the query to get total result in case i got to split it up in pages. So there is alot of if/else and sql = sql + "more stuff", and sticking to ? and pure prepared statements is impossible.
    But doing this is not good either:
    for( each element in a map)
      sql = sql + " and nvl( " + key + ",' ') like ?"
    }Where key is "artist".
    In struts and other tag libs its easy to make kode like:
    <s:textfield name="model.addSearch( 'artist' )" value="%{model.getSearch( 'artist' )}" size="30" />
    Silly example maybe, but just to make a point.
    Inputed values in an html form, can very easily be a part of a dynamic created sql - which becomes a security problem later on.
    Artist is an column name. Key should be validated if it contained an valid column name.
    I could make a list of strings, containing valid column names to check against.
    My question is if there is possible to get this type of information from the database, so I don't have to hand-make these lists?
    But I also want to keep the number of heavy and slowing queries down.
    My app have like 25 tables now, and I could easily get away with hand-make everything, copy/paste around etc. But I have more projects and this question will be here next time too. And after there again...

    Etharo wrote:
    Metadata. Then I have to query the database, take the result and use it for validating of input. If my sql only query 1 table, then this is ok. In this case I could do with that. But if the sql query mutliple tables, with sub-selects, unions etc. Then I might have to query all tables first, and even then I might not have what I want.
    The best way is of course to run the query, then get the metadata from that query - cause then im 100% sure what columns will be returned, and then I can validate with that.... 1 query is often not that slow. But I might query once to find total number of rows the query return in order to decide if we need to page the result. then query to get the metadata for validating input, then query to get the result... Maybe this is ok -but my head don't like it as an general ok thing to do, but I can't really say why...If you have a gui screen then it needs to correspond to some specific query. It can't be all possible combinations.
    So once you know the query you can obtain the meta data using a query that returns no results. Like the following.
    select * from mytable wheren 1 = 0
    >
    Jschell:
    I agree to what you say. I don't understood everything you said tho.
    Im not sure if you talk about having 1 search field (like google), and you input stuff there that might be in any columns.
    I have several search fields in one-to-one relasionship with view column/sql query column.
    Then you already know what the field represents. So validate it in the gui and not via the database.
    The first is way more advanced since you have to cover any input, any column, any case etc. Pluss add ranking. Lots of work for someone who have done little searchengines.
    Latter is simpler, but might also be limiting.Huh?
    As an example if you have a call center then the operators are not going to be doing unrestricted searches to find customers. They are going to look using a very limited set of data like the customer name and telephone number.
    >
    My job is very much like an consulent. They got an app, I shall add a new feature. The app is old and ugly coded. My boss ask how long it takes to make this, I say 2months, he decide 1 month. My dev time for features is rarely above 1 month, and I don't make much new apps.
    So I don't have the time to make advanced codegenerator, or spend time to evaluate various frameworks. Bringing an framework into the existing code is actually difficult. But I do want to improve the code, and add good code into the existing app that can be extended without evil pain.
    That doesn't jive with your OP. You made the following statement "My app have like 25 tables now, and I could easily get away with hand-make everything,...".
    That suggests that you are doing much more than simply updating an existing application.
    If you only need to add one new field then you should do only that. You shouldn't be attempting to add a system spanning validation system.
    On the other hand if you are in fact adding a validation system, then code generation makes it likely that it would take less time or no more than the same. And it is less likely to introduce bugs.
    Learn how to make an code generator? Well I guess thats what I asked help for - point me in the right direction if you could pls. Putting strings together to become code in an logic way is usually manageable, at least for simple querys. Evaluating that the generated code is good/safe - got no good clues...
    Learn about frameworks? Got no time. Hope I will get the time, but I won't. The customer must want to spend the money so I can get the time, that won't happen cause an framework does not add features, its only cost saving in terms of dev time, and maintenance time. The customer have no such focus/interest. They got a bit money to spend now and then regularily. i.e. government.
    I just want to try code as good as possible so I save myself from errors, painfull rewrites, and dev-time that gets out of proportions because of stupid code. So the question is actually about me trying to improve myself, its just that i don't know how right now.There are two goals.
    1. Implement a specific feature in an existing application.
    2. Learn a new way to solve problems.
    Nothing says that the second will help with the first. They should be addressed separately and your post doesn't make it clear what the first is so it is hard to say how it should be down.
    As for the second I already made a suggestion which provides two new ways to solve problems.

  • Unable To Use Regular Expression To Find Function Names

    Hi,
    I am trying to create a regular expression to find function and procedure names without the static designation and the parameter list.  Sample source document:
    static function test
    static function test(i,j)
    function test
    function test(i,j)
    static procedure test
    static procedure test(i,j)
    procedure test
    procedure test(i,j)
    For each of the above samples, I would like only the word "test" to be found.
    Thanks

    I suggest starting with this expression:
    ^\s*(static\s+)?(function|procedure)\s+(?<NAME>\w+)
    Programmatically, the name can be extracted from the group called “NAME”.
    The expression can be improved.

  • Regular expression to validate mail addresses

    I�m trying to create a regular expression able to validate mail address in a JFormattedTextField.
    I�m using the format defined in the java.util.regex.Pattern class.
    my current guess:
    "[[[a-zA-Z]+[0-9]*_*]+@[[a-zA-Z]+[0-9]*_*]+;]+"

    Have a look here:
    http://developer.java.sun.com/developer/technicalArticles/releases/1.4regex/
    There's an example mail validation program (not complete)

  • Regular expression to abbreviate the names

    Friends,
    I have tables names like MY_TABLE_NAME, and I need to generate the abbreviations for the tables as MTN. Can any one help me to get using regular expression?
    Thanks,
    Natarajan

    SQL> select table_name, regexp_replace(initcap(table_name), '[[:lower:]]|_') new_tab_name from user_tables
    TABLE_NAME                     NEW_TAB_NAME                 
    UT_METADATA                    UM                           
    V_DELIVERY_DC_DW               VDDD                         
    V_DBWE_DW                      VDD                          
    PLAN_ZIP                       PZ                           
    JOB_HISTORY                    JH                           
    DEMO_USERS                     DU                           
    DEMO_CUSTOMERS                 DC                           
    DEMO_ORDERS                    DO                           
    DEMO_PRODUCT_INFO              DPI                          
    DEMO_ORDER_ITEMS               DOI                          
    DEMO_STATES                    DS                           
    DEMO_PAGE_HIERARCHY            DPH                          
    PLAN_TABLE                     PT                           
    UT_LOOKUP_CATEGORIES           ULC                          
    MV_CORES                       MC                           
    PRODUCTS_QUALITY               PQ                           
    V_BSTPOS_DW                    VBD                          
    TRN_BR                         TB                           
    GL_BR                          GB                           
    V_FAKTUR_DW                    VFD                          
    CHANGE_LOGS                    CL                           
    V_FAKTUR_OLD_DW                VFOD                         
    T_EXT                          TE                           
    TRANSFER_GLOBAL                TG                           
    ORDER_LINES                    OL                           
    T_ERR                          TE                           
    UT_SUITE_TEST_RESULTS          USTR                         
    UT_SUITE_RESULTS               USR                          
    UT_TEST_RESULTS                UTR                          
    UT_TEST_COVERAGE_STATS         UTCS                         
    UT_TEST_IMPL_RESULTS           UTIR                         
    UT_TEST_IMPL_ARG_RESULTS       UTIAR                        
    UT_TEST_IMPL_VAL_RESULTS       UTIVR                        
    UT_SUITE_TEST                  UST                          
    UT_SUITE                       US                           
    UT_LIB_DYN_QUERIES             ULDQ                         
    UT_LIB_VALIDATIONS             ULV                          
    UT_LIB_TEARDOWNS               ULT                          
    UT_LIB_STARTUPS                ULS                          
    UT_TEST_IMPL_ARGUMENTS         UTIA                         
    UT_VALIDATIONS                 UV                           
    UT_TEST_IMPL                   UTI                          
    UT_TEST_ARGUMENTS              UTA                          
    UT_TEST                        UT                           
    UT_LOOKUP_VALUES               ULV                          
    UT_LOOKUP_DATATYPES            ULD                          
    ERR_DT                         ED                           
    47 rows selected.

  • MDS Business rule regular expression to validate code to be combination of two attributes

    Hi
    I need to have a business rule as below:
    entity1 have code, Attr1 and Attr2
    I have to ensure code is always combination of Attr1 and Attr2. If either of the Attr1 or Attr2 is blank, validation should fail.
    I tried below possibilities:
    1. Set Code to Auto generate
    2. Change tracking enabled for Attr1 and Attr2
    and below BRs:
    1. Attr1 has changed in group 1 AND (Attr2 has changed in group 1) then action:     Code equals a concatenated value Attr1 + Attr2
    2. Attr1 is equal to Blank OR Attr2 is equal to Blank then action:     Attr1 is required
        Attr2  is required
    3. Code must be unique Attr1 ,Attr2
    I see BRs 1 and 2 working. I have BR 3 to fail validation in case BR1 fails resulting code to remain auto generated value.
    but i dont see BR-3 working. At the end teh result is code with auto generated value validation is success.
    Is there a way i can overcome this issue?
    Any idea of referring attrbitues in Regular expression of this sort... to set Code equals to [Attr1] + [Attr2]?

    OK I bit the bullet and contacted support on this one.
    There is a known issue with MDS 2012 and business rules with a combination of "must be unique" attributes. If you do not list the attributes in the same order that they were created you will get the generic error I cited. At first they told me it must be
    in the same order the attributes are in and that worked on one entity but not the other. The difference was that in the second entity I previously rearranged the attributes in question. Once I changed the order in the business rule to reflect the *original*
    order it worked like a champ.
    Hopefully this helps save someone some time and money.

  • IR Report Computation Expression Column Name

    I am trying to generate a custom Report based on the Existing IR Report Conditions.
    One of My IR Report have a Computation column with Expression as To_Char(trunc(Y, 'YEAR'), 'YYYY') Where Y is the Column Identifier.
    My requirement is to substitute the Column Identifiers with the Exact column Name.
    For Ex: TO_CHAR(trunc(Report_Date, 'YEAR'), 'YYYY') where Report_Date is the Actual Column to be used. Apex substitutes the Identifier as Y.
    Another Example is CASE WHEN A = 10 THEN B + C ELSE B END
    Where A,B and C should be Substituted by their respective column Names.
    Is there a way to trace the column name used in the Expression or Frame the Expression with the Column Name.
    Hope i am clear in my Requirement.
    Thanks
    Sridhar

    Parse the statement character by character, and if the character is not surrounded by others except for a set of tokens (eg "'(),; ) then you have found an identifier. You can then map it to the correct column name by querying apex_application_ir_rpt and retrieving the report columns, mapping them to an identifier, and retrieving computation specifics from apex_application_ir_comp.
    But really, don't do this. (DON'T) It's a load of code and prone to errors. There is no simple way to parse these. It's a fun exercise, that's all.
    Rather tell us about what you're really trying to achieve. Why do you need a custom report when you already have the IR with the filters and computations on it?

  • Email validation using Regular Expression.

    Hi,
    I am in need of using a regular expression for email valiatino. ^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[A-Z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum)$ which is gotten from http://www.regular-expressions.info/email.html .
    This works fine in a regular expression test tool http://regexpal.com/ , but when I use in Oracle, it does not.
    DECLARE
    v_exp VARCHAR2(4000);
    BEGIN
       --v_exp := '^[a-z0-9!#$%&''*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&''*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[A-Z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum)$';
       v_exp := '^[a-z0-9!#\$%&''*+/=?\^_`{|}~-]+(?:\.[a-z0-9!#\$%&''*+/=?\^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[A-Z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum)$';
       dbms_output.put_line(v_exp);
       FOR v_rec IN (
          with test_data as
    ( select '[email protected]'     as val from dual union all
      select '[email protected]'       as val from dual union all
      select 'ad{[email protected]' as val from dual union ALL
      select '[email protected]' as val from dual union all 
      select '[email protected]' as val from dual union all 
      select '[email protected]'      as val from dual union all
      select 'no#good'                  as val from dual
    select
      val ,
      case
        when
          regexp_like
          (val, v_exp,'i') then 'Y'
        else 'N'
        end
        as good
    from test_data ) LOOP
       dbms_output.put_line(v_rec.val||', '||v_rec.good);
    END LOOP;  
    END;   and the results are
    [email protected], N
    [email protected], N
    ad{[email protected], N
    [email protected], N
    [email protected], N
    [email protected], N
    no#good, N
    The expected result should be Y for all but for the last two.
    I am not sure why it is not working in Oracle.
    Can any body please help me to find the mistake and to have it correctly?
    Advance Thanks,
    Natarajan
    Edited by: Nattu on Dec 4, 2012 1:31 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Try this regular expression:
    >> ^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$
    >> [email protected], *Y*
    >> [email protected], *Y*
    >> ad{[email protected], N
    >> [email protected], *Y*
    >> [email protected], *Y*
    >> [email protected], N
    >> no#good, N
    [Using a regular expression to validate an email address|http://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address]
    Edited by: stefan nebesnak on 4.12.2012 2:25                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Need regular expression for oracle date format 'DD-MON-YYYY'

    Hi,
    Can anybody tell me the regular expression to validate date in 'DD-MON-YYYY'.
    My concept is i have a table with just two columns item_name and item_date
    Both fields are varchar2 and i want to fetch those records from this table which have valid date format('DD-MON-YYYY').

    If it must be a regexp, this is a starter for you, note it carries the caveats mentioned by both posters above and in the linked thread
    mkr02@ORA11GMK> with data as (select '10-jan-2012' dt from dual
      2  union all select '10-111-2012' from dual
      3  union all select 'mm-jan-2012' from dual
      4  union all select '10-jan-12' from dual)
      5  select
      6  dt,
      7  case when regexp_like(dt,'[[:digit:]]{2}-[[:alpha:]]{3}-[[:digit:]]{4}','i') then 1 else 0 end chk
      8  from data
      9  /
    DT                 CHK
    10-jan-2012          1
    10-111-2012          0
    mm-jan-2012          0
    10-jan-12            0It will not validate content, only string format.
    And to emphasis the points made in the linked thread - dates in text columns is poor design. Always.

  • Regular Expression Challenge

    Hello, everybody!
    I'm trying to come up with a regular expression to validate a identifier that starts and ends with double quotes. That's what I have until now:
    \"[a-zA-Z_][\w]*\"
    This regex is working. It matches identifiers like:
    "name"
    "name_1"
    "_name123"but the challenge that I couldn't solve is this: I would like to augment this regex to also accept escaped double quotes inside the string itself, like this:
    "na""me"     (correct, double quote inside escaped by another double quote)
    "name""""_1" (correct, two double quotes inside escaped by double quotes)
    """_name123" (correct, double quote inside escaped by another double quote)and reject strings that miss the escape double quote, like the following:
    "na"me"
    "name""" "_1"
    "" "_name123"as you can see, besides the start and end quotes, if there's a double quote inside the identifier, it has to be followed +immediately+ by another double quote, it has to be a pair, no matter how many and where. I tried to find such a regular expression but I didn't have success. I couldn't find a way to say that a double quote inside the identifier has to be followed by another double quote.
    Any help would be appreciated.
    Thank you in advance.
    Marcos

    Marcos_AntonioPS wrote:
    r035198x wrote:
    Marcos_AntonioPS wrote:
    ..If you are not willing/able to learn about them and make an attempt then you will find it difficult to get help here.
    You will also find it difficult to get help if you insult regulars when they try to advise you on following the posting guidelines by chosing an appropriate thread title.r035198x, I didn't insult regulars. But you insulted me. I consider saying that I was trying to make someone here do 'my homework' an insult. I think that the worst insults in life are the ones that we say in a sarcastic manner, like yours.
    MarcosI can't think of one instance where a 'challenge' has been issued in these forums that was not an indirect request for someone's homework to be done. Yours could be the first but even then is stinks of "I can't be bothered to learn about look-ahead so can some kind person solve my problem for me?". Issuing a 'challenge' like this is an insult to us. It assumes we are gullible enough to do your work for you.
    You can get somewhere towards a solution using look-ahead but you will have to place restrictions since regex can't count.

  • In a Regular expressions I can set up an "OR" statement?

    HI, I'm using e-tester version 8.2..My problem is about regular expessions.
    I need to catch a dynamic value from a Form Field (My-TxtBox).. this textbox gets pre populated data ( when the customer has info in the database).. this is the code:
    *<input name="My-TxtBox" type="text" value="XXXX" id="ID-TxtBox"*
    ---- ( XXXX = dynamic number prepopulated by the web app)
    So, I'm using this regular expression:
    *<input name="My-TxtBox" type="text" value="(.+?)" id="ID-TxtBox"*
    -----At this point, everything is fine.. but there is an exception
    I'm getting a big problem when the customer doesn't have data in the server, the code is NOT like this
    <input name="My-TxtBox" type="text" value="" id="ID-TxtBox"
    When the customer doesn't have data in the server, the code is more like this:
    *<input name="My-TxtBox" type="text" id="ID-TxtBox"*
    ---- (please note that there is not a value parameter now)
    So, I think there is no way to create a CDV that will work for both cases? any idea to solve this?
    i was thinking that maybe in the reg exps sintax you can create an "OR" statement.. my idea was to create a CDV
    that works for both cases.. when there is the "value=" string and when there is not.
    something like this
    This CDV returns the dynamic value when there is the "value=" string =
    <input name="My-TxtBox" type="text" value="(.+?)" id="ID-TxtBox"
    And this CDV returns "" when there is no "value=" string = Without value:
    <input name="My-TxtBox" type="text" (.*?)id="ID-TxtBox"
    My idea is to place something like this in some point of the CDV = *{* value="(.+?)" *OR* (.*?) *}*
    so my dream is to create a CDV similar to this:
    <input name="My-TxtBox" type="text" { value="(.+?)" *OR* (.*?) }id="ID-TxtBox
    I was searching on google but I simply don't get an answer....it is posible to place an OR statement into a Reg Exp and how the sintax is? ..
    Regards.. I appreciate your time.

    Hola,
    You can use a regular expression such as:
    <input name="My-TxtBox" type="text" ?v?a?l?u?e?=?"?(.*?)"? id="ID-TxtBox"
    Note that:
    * Note that there is a question mark sign (?) after each letter that may appear in the string. This means that the letter may or may not appear.
    * Note that instead of using (.+?) you should use (.*?).
    This means that will match any character that appears zero or mutliple times. The question mark here means that is non-greedy, meaning that it will not include in the .* matching anything like the rest of the pattern (in this case the rest of the pattern is "? id="ID-TxtBox").
    * Note that the question mark in front of the v of value is there to match a space that may or may not exists.
    Few other facts:
    * In regular expressions the parenthesys determine sequence of operations and mark groups. Such groups can be referenced in code (not in etester but in general). In eTester it will always get the value of the first group (first group = first set of parenthesys).
    * ORs in regular expressions can be expressed with the pipe "|" (without the quotes), but you will need parenthesys in this case which would not allow you to capture the group of characters that you want.
    Regards,
    [Z]{1}uriel C?
    Edited by: Zuriel on Oct 5, 2009 3:07 PM
    Edited to avoid having the text changed by the forum formatting options.

  • Use regular expressions to extract .llb filename from path

    I am trying to be clever (always a dangerous thing) and use a regular expression to extract the name of a library from a filepath converted to a string.   Whilst I appreciate there are other ways to do this, regex would appear to be a very powerful neat way, should I be able to get it to work.
    i.e if I have a string of the type, C:\applications\versions\library.llb\toplevel.vi, I want to be able to extract library.llb from the string, given that it will be of variable length, may include numbers & spaces and may be within a file hierarchy of variable depth.   In other words, I want to extract the portion of the string between the last \ that ends with .llb
    The best I have managed so far, is \\+.*llb which returned everything minus the drive letter and the toplevel.vi
    Can anyone help me achieve this, or am i better using an alternative method (e.g filepath to array string, search for .llb)
    Thanks
    Matt
    Solved!
    Go to Solution.

    Hi Matt,
    attached you'll find two other options.
    Mike
    Message Edited by MikeS81 on 04-13-2010 01:30 PM
    Attachments:
    Path.PNG ‏7 KB

  • Using regular expressions for validation in i18n

    Can we use regular expressions for validation of inputs in a java application taking care of i18N aspects too. Zip code for different locales are different. Can we use regular expressions to validate zipcode inputs from different locales

    hi,
    For that shall i have to create individual patterns for matching the inputs from different locales or a single pattern will do in the case of validating phone nos. around the world, zip codes etc. In case different patterns are required, programmer should have a konwledge of difference in patters for different locales.
    regards
    sdas

  • Regular Expression Validation

    Hi,
    I'm trying to use a regular expression to validate password.
    I create a validation in my item called P502_PASSWORD. I choose regular expression type. At the Validation Expression 2, I put this expression:
    ^(?=.*\d)(?=.*[a-zA-Z])(?!.*[\W_\x7B-\xFF]).{6,15}$
    So, I tried to enter a valid "string" at this item. For example: abc123
    But it doesn't work and I don't know why. I have another item with a e-mail validation with the expression below, and works:
    ^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$
    So, i really don't know what is happening.
    Can someone help me? :)
    Thanks,
    Vivi

    Hi Vivi,
    I checked your regex with my favourite application and it seems to be correct for a 'liberal' interpreter. But POSIX-implementation in Oracle seems to be quite strict. At least, I get an ORA-12728 ("invalid range in regular expression") when executing your string with "REGEXP_LIKE". I would take the regex apart bit by bit and see when the regex starts to work with REGEXP_LIKE, like in the following example:
    BEGIN
      dbms_output.put_line(case when regexp_like('aBc123','^(((\d)|([[:alpha:]])){6,15})$') then 'hit' else 'miss' end);
    END;
    /This is of course not exactly the expression you wanted, but I guess it's not very far away and produces a 'hit'. ;)
    If anybody finds out what exactly caused the error I'd like to know. My first guess was the asterisk in combination with {6,15}, but just removing it didn't do the trick.
    -Udo

  • CharAt in a keystroke event using regular expression

    I'm working on a canadian postal code field.  I'm using a regular expression to validate the value.
    //accepts "A9A 9A9", "A9A9A9" or "" as valid entries excluding letters D, F, I, O, Q, U and W as well as Z as the first digit.
    var re = /^[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJKLMNPRSTVWXYZ]( )?\d[ABCEGHJKLMNPRSTVWXYZ]\d$|^$/i;
    if(re.test(event.value) == false){
    app.alert("Code postal invalide", 0, 0,"CODE POSTAL");
    event.value = "";
    I also added a keystroke event to prescan every digit and toUpperCase() them.
    //accepts letters, numbers, backspace or spaces
    var re = /[ABCEGHJKLMNPRSTVWXYZ]|\d|^$|\s/i;
    if (!event.willCommit){
    if(re.test(event.change) == false){
      event.rc = false;
    else{
      event.change = event.change.toUpperCase();
    I want to Replicate the behavior of an arbitrary mask where I can force a character to appear at a specific position.  In this example, instead of letting the user decide wether he adds a "space" or not between the two parts of the code, I want to:
    1-Remove "\s" in the keystroke regexp so the user cannot use "space";
    2-Replace "( )?" for "( )" in the validation regexp;
    3-Force a space at charAt(3).
    Is it possible to have it appear while the user is still typing or is my only option to change the value once committed or as a cutom format script?
    In the same manner, is it possible to specify a different regexp keystroke depending on the position of each character?
    charAt(0), charAt(2), charAt(5) would be letters
    charAt(1), charAt(6), charAt(7), would be numbers
    charAt(3), would automatically add a "space"
    in the end, I want the same behavior as an arbitrary mask without the annoying alert when entering a wrong digit.

    The entire string validation is different from the keystroke validation. The keystroke validation can check each keystroke as it is typed while the string validation can only process the entire string at one time.
    You need to break your RegExp to describe the requirement for each character. You can even specify the possible number of repetitions of the pattern.
    A discussion on to create keystroke validations would be far too long for a post in a forum.
    Acuumnen has an ebook about Acrobat forms and has a couple of chapters to some simple validation and formatting scripts.

Maybe you are looking for

  • How to search text content of scanned Documents in DMS

    hello, i need to scan the legacy document and put it in to DMS. After that i want to search the scanned document using the Trex search. I want to know how to achive it as scaaed document are as like images and we can not search the text in images. An

  • Good Mic for Sound Card / Creative Labs sound blaster c

    Can anyone recommend a good mic for my soundblaster sound card. Not too expensi've. Currently using cheap pc mic that can with my computer. Need better mic to for vocal DJ'ing stuff.. Thanks

  • Solaris 8 installation problems

    Hello, I'm trying to install Solaris 2.8 on a Compaq server. I have the tree cd's downloaded from your site. config: internal ultra scsi 2 ctrlr with 1 * 18gb H/D internal ide ctrlr with cd drive and diskette drive In both ways , i do an update drive

  • Python API files

    Hi, These (generated?) files are instrumental in library function names autocompletion or calltips or some such things. Some genius invented a killer name for them (pun intended). This API acronym virtually disables Google. I'd be most grateful for s

  • LegendItem dynamic insertion

    Hello, I'm writting and application that repopulates a legend quite frequently. I've written some code in Flex 3.0 to accomplish this. Here is the main function that does the work:     signalLegend.removeAllChildren();     for (var i:int = 0; i < num