CFFORM regex Problem

I'm trying to restrict a form value to something like mm/dd
as follows:
<cfinput type="text" name="AnStartDate#i#"
id="AnStartDate#i#" validate="regular_expression"
pattern="^[0-1]?[0-9]/[0-3]?[0-9]*$" size="4" maxlength="5"
validateat="onSubmit" message="Please enter all annual start dates
as mm/dd" />
The form loops to give a total of 5 rows of text entries.
When the page loads, Firefox's Javascript console shows the
following error:
Error: syntax error
Source File:
http://localhost/mti/orders/refurb/edit_duty.cfm?type=Argos%2FGPS%20Solar%20PTTs&prodID=79
Line: 196, Column: 92
Source Code:
if (!_CF_checkregex(_CF_this['AnStartDate1'].value,
/^[0-1]?[0-9]/[0-3]?[0-9]*$/, true))
with the arrow indicating the error is right before the
"true" at the end of the statement.
Since this is in the JS generated by CF, is there a problem
in the regular expression? I want the initial digit of the month or
day to be optional, so users can type, "6/4" rather than "06/04"
but it needs to be no more that 5 characters, and look like a date
without a year. Right now, because of the error, anything is
accepted.

You need to escape your "/".
^[0-1]?[0-9]\/[0-3]?[0-9]*$
Just an FYI, the only thing this is validating is that you
have 1 or 2 digits who's value is lte 19 followed by a "/" followed
by one or 2 digits who's value is lte 39. The values 19/39 or 00/00
would pass the test despite the fact they're far from being a valid
date.

Similar Messages

  • Cfform regex validation message

    I have a problem returning my message text when validating a
    cfinput field against a regular expression on CF8, as follows:
    <cfinput type="text" name="AddrTitle" id="AddrTitle"
    size="50" maxlength="250" value="#AddrTitle#"
    validate="regular_expression" pattern="[\w_-]*"
    validateat="onsubmit,onserver" message="Use only alphanumeric
    characters or - (dash) or _ (underscore) only for the address bar
    title" />
    Instead of a javascript pop-up message (which I would
    expect), I get the server response using the default CF error
    response (The value entered in the field ADDRTITLE is not correctly
    formatted for the pattern [\w_-]*.)
    In the same form, a date field validates just fine and
    displays my message text properly, both in a javascript message box
    or server side, when I have disabled javascript, so the cfform.js
    file is available (I have checked this though the address bar too).
    Does anyone know why the regex validated field isn't
    displaying my custom message?

    Hi,
    Automatically, you can include only whole validation in your change request. But, you can create a manual change request for this message only. This definition is stored in GB931 table.
    Regards,
    Eli

  • RegEx Problem with flag COMMENTS

    Hello,
    I have the following Exception:
    java.util.regex.PatternSyntaxException: Unclosed group near index 9
    when my program is running with this flags:
    Pattern patt = Pattern.compile("^(@#@.+)$", Pattern.MULTILINE | Pattern.COMMENTS);but when I run this:
    Pattern patt = Pattern.compile("^(@#@.+)$", Pattern.MULTILINE);it works fine.
    Any COMMENTS ;-) for this problem? The entire RegEx is much bigger. I want to comment it.
    Thanks sacrofano

    Hi,
    thanks for your help, but it did not work.I did not suggest anything that would work! I was trying to point out that the Javadoc says that everything from # to the end of the pattern is treated as comment.
    I run this
    Pattern patt =
    Pattern.compile("^(?:(@#@.+))$",(Pattern.COMMENTS));[/
    code]So why, based on reading the Javadoc, would you expect this RE to compile? Everything after the # is treated as comment so your effective regular expression is "^(?:(@" which is obviously an invalid RE!
    with same exception as above.
    Is there a problem with the Flag Pattern.COMMENTSNo! RTFD.

  • Phone field regex problem

    Hi, I need a little help with my regex... it works good, except for one last issue.
    /^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4} ?)$/
    I have a single phone field. And  it to allows just 10 digits, or digits with dashes, or digits with parenthesis, or digits with spaces. And it even allows the user to insert a white space at the end (by accident).  This all works good.
    But I was told that no area codes in the US start with a 0 or 1?  How can I make it only have a range of 2 to 9 for the area code?
    I tried to use [2-9] but this doesn't work.
    Thanks in advance!

    The problem is that you are trying to match three digits with a [2-9] range, not just the first number.
    for example:
    333-444-555 will match because all three of the first section of digits are between 2 and 9,
    211-222-333 will not work, because 1, is the second number and you are only looking for 2-9.
    does this make sense? you have the three first numbers group together in one rule
    -Julia

  • Small RegEx problem

    Hello fellow Programmers!
    I turn to you because this small regular expression is turning me NUTS! AHHH!
    My String:
    blalba[morebla]evenmorebla]blaMy RegEx:
    \[.*(\]){1}My Aim:
    To get the first Bracket and everything between and inculding the second bracket. So that would be:
    "[morebla]"
    The Problem is I get the first bracket and everything until the LAST bracket.
    "[morebla]evenmorebla]"
    I assume this is so because ".*" just runs over everything until a final bracket appears...
    Any thoughts?

    anox wrote:
    Smithberrys suggestion worked.
    The other one didn't work out with my regEx but I am currently looking into that question mark and its functions.
    Thanks guys!Didn't work? How did you use it? Where did you use it?
    public class RegexpSample {
        public static void main(String[] args) {
            String data = "blalba[morebla]evenmorebla]bla";
            Matcher matcher = Pattern.compile("\\[.*?\\]").matcher(data);
            matcher.find();
            System.out.println(matcher.group());
    }Prints:
    [morebla]
    * is normally greedy, and a question mark makes it reluctant.
    You can find more info in the javadoc for the Pattern class, and on www.regular-expressions.info
    Kaj

  • Mod_Rewrite/Restart Regex Problem

    I'm trying to migrate to SJWS 7.0R1 from Apache, and trying to migrate the following rewrite functionality:
    Rewriterule ^(.*/)$ asp.php?url=$1index
    Rewriterule ^$ asp.php?url=index
    Rewriterule ^admin(/+(.*))?$ admin.php?url=$2
    RewriteCond %{REQUEST_FILENAME} !-f
    Rewriterule ^(.+)\.asp$ asp.php?url=$1&%{QUERY_STRING}
    RewriteCond %{REQUEST_FILENAME} !-f
    Rewriterule ^([^\.]+)$ asp.php?url=$1
    RewriteCond %{REQUEST_FILENAME} !-f
    Rewriterule ^(.+)$ file.php?url=$1
    I've successfully started with redirecting the base to asp.php?url=index, but beyond that, I'm getting errors related to either the backreference not being picked up, or being undefined. The URL I'm working with at the moment is:
    (From the Virtual Server's obj.conf file)
    <Object name="default">
    NameTrans fn="restart" from="/" uri="/asp.php?url=index" (This Works)
    This directive (See Error #1)
    <If $uri =~ "^/([a-z].*)">
    NameTrans fn="restart" uri="/file1.php?q=$1"
    </If>
    or, this directive (See Error #2)
    <If $uri =~ "^/([a-z].*)">
    NameTrans fn="restart" from="^/([a-z].*)" uri="/file1.php?q=$1"
    </If>
    The errors that I'm getting:
    Original URL: /sun_components/index.asp
    Error #1:
    failure (24219): trying to GET /file1.php whiletrying to GET /asp.php while trying to GET /, HTTP2297: Cannot restart request for /file1.php?q=file1.php (Exceeded maximum of 50 restarts)
    (Notice that the backreference doesn't get picked up, and is instead referencing file1.php)
    Error #2:
    failure (24219): for host XXXXX trying to GET /sun_components/index.asp, handle-processed reports: TTP2298: Error interpolating parameters for restart (Backreference $1 undefined)
    Thanks very much in advance for any help you can give me.
    -Doug

    OK, I had used the $restarted check, and that's all working great. However, on a separate VirtualServer, I'm having the following problem: when I include the $restarted check, it returns a 404 error; when I remove it, it ends up in an infinite loop. If I manually put in the rewritten url, all works fine. Logs are below, which show that it restarts, but after it restarts, it continues trying to process on the original URI, rather than on the restarted one.
    [12/Dec/2007:11:19:15] finest ( 7564): for host XX trying to GET /new_hampshire/docs/990_party_stores/index.php, =~ reports: Subject "/new_hampshire/docs/990_party_stores/index.php" matches pattern "^/new_hampshire/docs(.*)$" with 1 capturing subpattern(s)
    [12/Dec/2007:11:19:15] finest ( 7564): for host XX trying to GET /new_hampshire/docs/990_party_stores/index.php, func_exec reports: executing fn="restart" uri="docs.php?url=/990_party_stores/index.php" Directive="NameTrans"
    [12/Dec/2007:11:19:15] fine ( 7564): for host XX trying to GET /new_hampshire/docs/990_party_stores/index.php, restarting request as docs.php?url=/990_party_stores/index.php
    [12/Dec/2007:11:19:15] finest ( 7564): for host XX trying to GET /new_hampshire/docs/990_party_stores/docs.php while trying to GET /new_hampshire/docs/990_party_stores/index.php, func_exec reports: fn="restart" uri="docs.php?url=/990_party_stores/index.php" Directive="NameTrans" returned -4 (REQ_RESTART)
    [12/Dec/2007:11:19:15] finest ( 7564): for host XX trying to GET /new_hampshire/docs/990_party_stores/docs.php while trying to GET /new_hampshire/docs/990_party_stores/index.php, process-uri-objects reports: processing objects for URI /new_hampshire/docs/990_party_stores/docs.php
    [12/Dec/2007:11:19:15] finest ( 7564): for host XX trying to GET /new_hampshire/docs/990_party_stores/docs.php while trying to GET /new_hampshire/docs/990_party_stores/index.php, process-uri-objects reports: adding object name="default"
    [12/Dec/2007:11:19:15] finest ( 7564): for host XX trying to GET /new_hampshire/docs/990_party_stores/docs.php while trying to GET /new_hampshire/docs/990_party_stores/index.php, func_exec reports: executing fn="match-browser" browser="*MSIE*" ssl-unclean-shutdown="true" Directive="AuthTrans" magnus-internal="1"
    [12/Dec/2007:11:19:15] finest ( 7564): for host XX trying to GET /new_hampshire/docs/990_party_stores/docs.php while trying to GET /new_hampshire/docs/990_party_stores/index.php, func_exec reports: fn="match-browser" browser="*MSIE*" ssl-unclean-shutdown="true" Directive="AuthTrans" magnus-internal="1" returned -2 (REQ_NOACTION)
    [12/Dec/2007:11:19:15] finest ( 7564): for host XX trying to GET /new_hampshire/docs/990_party_stores/docs.php while trying to GET /new_hampshire/docs/990_party_stores/index.php, func_exec reports: executing fn="ntrans-j2ee" name="j2ee" Directive="NameTrans"
    [12/Dec/2007:11:19:15] finest ( 7564): for host XX trying to GET /new_hampshire/docs/990_party_stores/docs.php while trying to GET /new_hampshire/docs/990_party_stores/index.php, func_exec reports: fn="ntrans-j2ee" name="j2ee" Directive="NameTrans" returned -2 (REQ_NOACTION)
    [12/Dec/2007:11:19:15] finest ( 7564): for host XX trying to GET /new_hampshire/docs/990_party_stores/docs.php while trying to GET /new_hampshire/docs/990_party_stores/index.php, func_exec reports: executing fn="pfx2dir" from="/mc-icons" dir="/sun/webserver7/lib/icons" name="es-internal" Directive="NameTrans"
    [12/Dec/2007:11:19:15] finest ( 7564): for host XX trying to GET /new_hampshire/docs/990_party_stores/docs.php while trying to GET /new_hampshire/docs/990_party_stores/index.php, func_exec reports: fn="pfx2dir" from="/mc-icons" dir="/sun/webserver7/lib/icons" name="es-internal" Directive="NameTrans" returned -2 (REQ_NOACTION)
    [12/Dec/2007:11:19:15] finest ( 7564): for host XX trying to GET /new_hampshire/docs/990_party_stores/docs.php while trying to GET /new_hampshire/docs/990_party_stores/index.php, func_exec reports: executing fn="check-acl" acl="default" Directive="PathCheck"
    [12/Dec/2007:11:19:15] finest ( 7564): for host XX trying to GET /new_hampshire/docs/990_party_stores/docs.php while trying to GET /new_hampshire/docs/990_party_stores/index.php, func_exec reports: fn="check-acl" acl="default" Directive="PathCheck" returned -2 (REQ_NOACTION)

  • Java regex problem

    Hi:
    I have the following texts in a flat file:
    scheduler is running
    system default destination: llp
    device for ps3: /dev/ps3
    device for ps: /dev/ecpp0
    device for llp: /dev/ecpp0
    How can I use java regex to print out the string after "device for " in this case the string "ps3" ,"ps" and "llp".

        static final Pattern DEVICE_PATTERN = Pattern.compile(
                                          "device for ([^:]++)" );
        String text = "";
        Matcher m = DEVICE_PATTERN.matcher( text );
        while ( (text = bufferedReader.readLine()) != null ) {
            if ( m.reset(text).lookingAt() ) {
                String device = m.group( 1 );
        }

  • Regex problem: return all solutions

    Hi all,
    I would like to force backtracking on a regular expression, in order to return ALL POSSIBLE SOLUTIONS. For example, the regex:
    (a*(b))
    applied on "aaaab" on the group0 returns:
    "aaaab"
    I would like it to return:
    "aaaab"
    "aaab"
    "aab"
    "ab"
    "b"
    that is, all solution for group0.
    Do you know how to do it? As far as I know, using the Matcher.group(int) method it only return the LAST finding of the group (in my case "aaaab", or "ab" if you use lazy).
    Thank!
    Legolas

    Yes, I though about this solution, but it seems to me a little "dirty" and inefficient...
    It seems me so strange that they didn't try to implement class method that does backtracking !! (to emulate a declarative language, eg Prolog)
    Anyway, thaks a lot...it seems the only possibile solution to force explicitely the backtrack.
    Legolas

  • Simple regex problem

    In the application that I'm working on, input is validated while the user is typing, i.e. an entire text field is validated every time that a new character is inserted. I'm trying to check for a valid decimal number using this regular expression. (I know that it will also be true for blank values, but parseDouble() should take care of that.) Can anyone see something wrong here? My textfield doesn't accept any input when validation takes place using this expression.
    //Decimal numbers
        public final static String DECIMALNUMERIC = "[0-9]*\\.*[0-9]*";

    sabre150 wrote:
    codingMonkey wrote:
    prometheuzz wrote:
    But a better approach would probably be to use a JFormattedTextField:
    [http://java.sun.com/docs/books/tutorial/uiswing/components/formattedtextfield.html]
    No can do. My company has a bunch of components that we've made specifically for the system that we're working on. That expressions looks a bit to big and complicated for something as simple as this, and I don't have to cater for negative values.
    Yet they allow you to use a piss poor regex to validate a number and they allow the abomination you propose in http://forum.java.sun.com/thread.jspa?threadID=5278584&messageID=10168724#10168724 . Wow!
    Why is that so terrible?

  • Regex Problem Using && and  ^  With Code

    When I create a pattern that uses the && or the ^ symbol it does not give me the result data.
    && is for LOGICAL AND intersection matches of data and ^ for except
    matches
    The code is below
    import java.lang.*;
    import java.util.regex.*;
    * <p>Title: RegexTest</p>
    * <p>Description: java version of hesd</p>
    * <p>Copyright: Copyright (c) 2003</p>
    * <p>Company: </p>
    * @author MR Lewis
    * @version 1.0
    public class RegexTester
    static final int NUMBEROFSTRINGS=4;
    static final int NUMBEROFEXPRESSIONS=7;
    static final int NUMBEROFTESTS=28;
    static Matcher regexMatcher;
    static String strTestString1 ="MoonRd 115 PCB 356338_NPC ... Rtn to Normal 114.47 KV !2.123088";
    static String strTestString2 ="VillaRica 115 PCB 356338_NPC ... Fail 237.47 KV !2.123089";
    static String strTestString3 ="Norcross 115 PCB 356338_NPC ... Fail 107.47 KV !2.123090";
    static String strTestString4 ="MrLewisRd 230 PCB 356338_NPC ... LO OPLmt 114.47 KV !1.123091";
    static Pattern ptnCompiledExpression=null;
    public RegexTester()
    public static void main(String[] args)
    boolean blnPatternFound=false;
         boolean blnRunLoop=true;
         int iWhileLoop=0;
         int iForLoop=0;
         int intTestNumber=1;
         int three=3;
         int one=1;
         int intExpressionNumber=0;
         String strTestStringTemp="";
         String strTestExpressionTemp="";
         String [] arrTestStrings = new String[NUMBEROFSTRINGS];
         String [] arrTestExpressions = new String[NUMBEROFEXPRESSIONS];
    arrTestExpressions[0]="MoonRd|PCB"; //TEST OR EXPRESSION
    arrTestExpressions[1]="Vill&&Normal"; //TEST AND EXPRESSION **DOES NOT WORK**
    arrTestExpressions[2]="^Fail"; //TEST ^ EXCEPTION EXPRESSION **DOES NOT WORK**
    arrTestExpressions[3]="PCB"; //TEST REGULAR PATTERN
    arrTestExpressions[4]="^(!2)"; //TEST OF ^ EXCEPTION ANOTHER WAYE **DOES NOT WORK**
    arrTestExpressions[5]="(!1)"; //TEST OF PATTERN
         arrTestStrings[0] ="MoonRd 115 PCB 356338_NPC ... Rtn to Normal 114.47 KV !2.123088";
         arrTestStrings[1] ="VillaRica 115 PCB 356338_NPC ... Fail 237.47 KV !2.123089";
         arrTestStrings[2] ="Norcross 115 PCB 356338_NPC ... Fail 107.47 KV !2.123090";
    arrTestStrings[3] ="MrLewisRd 230 PCB 356338_NPC ... LO OPLmt 114.47 KV !1.123091";
         RegexTester regexTest1 = new RegexTester();
         while(blnRunLoop)
    if(iWhileLoop==0){strTestExpressionTemp=arrTestExpressions[0];} //test each expression
         else{strTestExpressionTemp=arrTestExpressions[intExpressionNumber];} //test each expression
         systemlog("\n\nTest #"+intTestNumber+ "-"+(intTestNumber+three)+"\t\t<"+strTestExpressionTemp+">");
         systemlog("------------------------------------------------------------");
         for(; iForLoop<NUMBEROFSTRINGS; iForLoop++)
         strTestStringTemp=arrTestStrings[iForLoop];
              ptnCompiledExpression = compilepatterns(strTestExpressionTemp);
         regexMatcher = ptnCompiledExpression.matcher(strTestStringTemp);
         blnPatternFound=regexMatcher.find();
         if(blnPatternFound)
              systemlog("\tFound: "+strTestStringTemp);
         else
              systemlog("\tNOTHING TO REPORT USING: "+strTestExpressionTemp);
         intTestNumber++;
              if(iForLoop==3){intExpressionNumber++;}
         iForLoop=0;
         regexMatcher.reset();
         iWhileLoop++;
         if((intTestNumber+three)==NUMBEROFTESTS){blnRunLoop=false;break;}
    private static synchronized Pattern compilepatterns (String strExpression)
         Pattern ptnReturn;
         ptnReturn = Pattern.compile(strExpression);
    // systemlog("Complied=>"+ ptnReturn.pattern().toString()+"<=Expression");
         return(ptnReturn);
    private static void systemlog (String strSystemMessage)
         System.out.println(strSystemMessage);
    Have you ran across any issues with this?
    Are there some search limitations ?
    Based on the following input data
    "MoonRd 115 PCB 356338_NPC ... Rtn to Normal 114.47 KV !2.123088";
    "VillaRica 115 PCB 356338_NPC ... Fail 237.47 KV !2.123089";
    "Norcross 115 PCB 356338_NPC ... Fail 107.47 KV !2.123090";
    "MrLewisRd 230 PCB 356338_NPC ... LO OPLmt 114.47 KV !1.123091";
    Test #1-4          <MoonRd|PCB>
    Found: MoonRd 115 PCB 356338_NPC ... Rtn to Normal 114.47 KV !2.123088      
    Found: VillaRica 115 PCB 356338_NPC ... Fail 237.47 KV !2.123089      
    Found: Norcross 115 PCB 356338_NPC ... Fail 107.47 KV !2.123090      
    Found: MrLewisRd 230 PCB 356338_NPC ... LO OPLmt 114.47 KV !1.123091
    Test #5-8          <Vill&&Normal>
    NOTHING TO REPORT USING: Vill&&Normal      
    NOTHING TO REPORT USING: Vill&&Normal      
    NOTHING TO REPORT USING: Vill&&Normal      
    NOTHING TO REPORT USING: Vill&&Normal
    Test #9-12          <^Fail>
    NOTHING TO REPORT USING: ^Fail      
    NOTHING TO REPORT USING: ^Fail      
    NOTHING TO REPORT USING: ^Fail      
    NOTHING TO REPORT USING: ^Fail
    Test #13-16          <PCB>
    Found: MoonRd 115 PCB 356338_NPC ... Rtn to Normal 114.47 KV !2.123088      
    Found: VillaRica 115 PCB 356338_NPC ... Fail 237.47 KV !2.123089      
    Found: Norcross 115 PCB 356338_NPC ... Fail 107.47 KV !2.123090
    Found: MrLewisRd 230 PCB 356338_NPC ... LO OPLmt 114.47 KV !1.123091
    Test #17-20          <^(!2)>
    NOTHING TO REPORT USING: ^(!2)      
    NOTHING TO REPORT USING: ^(!2)      
    NOTHING TO REPORT USING: ^(!2)      
    NOTHING TO REPORT USING: ^(!2)
    Test #21-24          <(!1)>
    NOTHING TO REPORT USING: (!1)      
    NOTHING TO REPORT USING: (!1)      
    NOTHING TO REPORT USING: (!1)      
    Found: MrLewisRd 230 PCB 356338_NPC ... LO OPLmt 114.47 KV !1.123091

    The first solution yeilded the following which is still wrong.
    here is there result when I use the \\&\\& and the \\^ which is still wrong.
    how come there is no easy way to just say give me the lines that match vill and fail
    Test #1-4          <MoonRd|PCB>
         Found: MoonRd 115 PCB 356338_NPC ... Rtn to Normal 114.47 KV !2.123088
         Found: VillaRica 115 PCB 356338_NPC ... Fail 237.47 KV !2.123089
         Found: Norcross 115 PCB 356338_NPC ... Fail 107.47 KV !2.123090
         Found: MrLewisRd 230 PCB 356338_NPC ... LO OPLmt 114.47 KV !1.123091
    when I Used the \\&\\&
    Test #5-8          <Vill\&\&[Normal]>
         NOTHING TO REPORT USING: Vill\&\&[Normal]
         NOTHING TO REPORT USING: Vill\&\&[Normal]
         NOTHING TO REPORT USING: Vill\&\&[Normal]
         NOTHING TO REPORT USING: Vill\&\&[Normal]
    Test #9-12          <\^Fail>
         NOTHING TO REPORT USING: \^Fail
         NOTHING TO REPORT USING: \^Fail
         NOTHING TO REPORT USING: \^Fail
         NOTHING TO REPORT USING: \^Fail
    Test #13-16          <PCB>
         Found: MoonRd 115 PCB 356338_NPC ... Rtn to Normal 114.47 KV !2.123088
         Found: VillaRica 115 PCB 356338_NPC ... Fail 237.47 KV !2.123089
         Found: Norcross 115 PCB 356338_NPC ... Fail 107.47 KV !2.123090
         Found: MrLewisRd 230 PCB 356338_NPC ... LO OPLmt 114.47 KV !1.123091
    Test #17-20          <\^(!2)>
         NOTHING TO REPORT USING: \^(!2)
         NOTHING TO REPORT USING: \^(!2)
         NOTHING TO REPORT USING: \^(!2)
         NOTHING TO REPORT USING: \^(!2)
    Test #21-24          <(!1)>
         NOTHING TO REPORT USING: (!1)
         NOTHING TO REPORT USING: (!1)
         NOTHING TO REPORT USING: (!1)
         Found: MrLewisRd 230 PCB 356338_NPC ... LO OPLmt 114.47 KV !1.123091

  • Keystroke regular expression (regex) problem

    I have a text field that should only permit the following values: "V", "X" or "NA" (all uppercase).
    I'm fairly OK with javascript in pdf and I have a script that validates these when the field losses focus.
    What would be much better is to have a keystroke script that only permits these values to be entered. I've found elsewhere in the forums a useful starting point here:
    var re = /^[A-Za-z0-9 :\\_]$/;
    event.change = event.change.toUpperCase();
    if (event.change.length >0) {
    if (event.willCommit == false) {
        if (!re.test(event.change)) {
            event.rc = false
    but I've been unable to come up with anything for the regexp pattern that works reliably (these are definitely not my strong point).
    Grateful thanks for any help.

    You can apply the RegEX to the keystroke and restrict the keystroke values that be entered or you can use the validation tab to enter a script to restrict the input to specific values.
    The script you are using only checks the entered character so it will not test the string "NA" which is 2 characters.
    Another approach for such a limited number of input options would be a combo box  or drop down box where the options are space, "V", "X", and "NA". The value of the field would then be limited to a space (no selection made), a V, X, or NA.

  • Tricky regex problem

    OK it's late but this one has me stumped. I need to
    dynamically change URLs in a block of HTML. Sounds easy, except
    what if the URL is something like "/index.cfm" that I want to
    change to, say, "/newdir/index.cfm".
    In other words, I'd want all these to match:
    /index.cfm
    http://www.site.com/index.cfm?name=value
    ftp://www.anothersite.com/index.cfm
    But definitely NOT anything that's a different URL, like:
    /subdir/index.cfm
    Basically, I don't want a situation where /subdir/index.cfm
    is translated into /subdir/newdir/index.cfm
    To that end, I figured I'd take any match for my directory,
    EXCEPT where it was immediately preceded by some other subdirectory
    . However, the only way I can think of to do this is with an
    intermediary value, as in:
    HTMLString = 'a href="/leavethisalone/index.cfm" a
    href="/index.cfm?name1=var1"';
    HTMLString = REReplaceNoCase(HTMLString,
    "(\/[0-9a-zA-Z\-]+)\/index.cfm", "\1SomethingThatIsNeverInHTML",
    "ALL");
    HTMLString = replaceNoCase(HTMLString, "\/index.cfm",
    "/newDirectory/index.cfm", "ALL");
    HTMLString = replaceNoCase(HTMLString,
    "SomethingThatIsNeverInHTML", "/index.cfm", "ALL");
    This gets expensive as I'm doing two extra replaces. Is there
    a way to just do this in one go?
    Thanks,
    - Andrew.

    Your problem can get tricky but as you've described it, this
    should work:
    REReplaceNoCase (" " & HTMLString, "(
    http://[0-9a-z_\.-
    "\1/newdir/index.cfm", "ALL");

  • Regex Problem

    hi all,
    I wanna know how to check whole string using java regular expressions?
    e.g.
    i want to test whther 123 contains only number or not?
    "123".matches("\\d") is it corect?
    And if i want to check maltec shouls contain only alphabetci characters or not
    "maltec".matches("[a-zA-z]") is correct?
    Correct me.. And guide me how to check whole strings in a proper manner

    Maltec wrote:
    hi all,
    I wanna know how to check whole string using java regular expressions?
    e.g.
    i want to test whther 123 contains only number or not?
    "123".matches("\\d") is it corect?No - "123".matches("\\d+") And if i want to check maltec shouls contain only alphabetci characters or not
    "maltec".matches("[a-zA-z]") is correct?No - "maltec".matches("[a-zA-z]+")>
    Correct me.. And guide me how to check whole strings in a proper manner

  • Regex problem using Pattern class

    Hi everybody,
    I am using the Pattern class to create a pattern which has to match "Sanofi-Aventis" (without the quotes). The pattern is created like this:
    Pattern p = Pattern.compile("(?i)(" + Pattern.quote(match) + ")");It is then matched as follows:
    Matcher m = p.matcher(retval);
    String retval = m.replaceAll("<font color=\"#CCCCCC\"><strong>$1</strong></font>");I have printend the value of "match" and of "Pattern.quote(match)", and they look like this:
    >
    match: Sanofi-Aventis
    Pattern.quote(): \QSanofi-Aventis\E
    However, "Sanofi-Aventis" does not get matches in the text. Words / Strings without a "-" work fine, so I guess I am doing something wrong with respect to the dash. Can anybody help me out?
    Best regards,
    Jethro

    Hi there,
    I now sort the p_matches ArrayList on String length to make sure I find the longest possible match. Besides that I am now using the CASE_INSENSITIVE flag instead of "(?i)". This is my final code:
    public static String colorOccurences(String p_text, ArrayList<String> p_matches, String p_HTMLColorCode)
         String retval = p_text;
            // Sort the matches ArrayList on String length, starting with the longest String.
            Collections.sort(p_matches, new StringLengthComparator());
            // Color the matches.
            for (String match : p_matches)
                Pattern p = Pattern.compile("(" + Pattern.quote(match) + ")", Pattern.CASE_INSENSITIVE);
                Matcher m = p.matcher(retval);
                retval = m.replaceAll("<font color=\"" + p_HTMLColorCode + "\"><strong>$1</strong></font>");
         return retval;
    * Comparator object for Strings. Orders by length of String from large to small,
    * then alphabetically.
    private static class StringLengthComparator implements Comparator
         public int compare(Object x,Object y)
              if(x instanceof String && y instanceof String)
                   String xstr = (String) x, ystr = (String) y;
                   if(xstr.length() == ystr.length()) return xstr.compareTo(ystr);
                   else if(xstr.length() < ystr.length()) return 1;
                   else return -1;
              else return 0;
    }Best regards,
    Jethro

  • Problem using Regex with ResourceBundle

    Hi,
    i'm using a ResourceBundle to store I18N strings in various languages. Now when I try to use those as patterns in a Regex, it just doesn't match.
    Here is a sample string:
    Mode lecture : S�curis� SANS C2, Flux pr�cis, Cache d�sactiv�
    In the ResourceBundle it looks like this, encoded as Unicode codepoints:
    eaclog.1254=S\u201acuris\u201a SANS C2, Flux pr\u201acis, Cache d\u201asactiv\u201a
    When I retrieve the regex pattern (myPattern.pattern()), it looks like this on the console:
    S�curis� SANS C2, Flux pr�cis, Cache d�sactiv�
    It seems like the encoding in the regex isn't right. What have I done wrong?

    Cool, thanks for the reply. The character encoding was broken even before I converted it using natice2ascii, now it works!
    From now on, I will always use the "-reverse" option to see if the output looks right. Boy, and I thought it was some weird regex problem...

Maybe you are looking for

  • My iPod Touch is stuck in Recovery mode and would not respond. Please Help!

    Hi! I have an iPod Touch 2nd Generation 8GB. Yesterday, I tried to update to iOS 4.0 from 3.1.3 by way of shift-click restore because my iPod was jailbroken. When the restore process was about 95% done, I received a "Send Error Report" and in every t

  • "What's new" crashes the page when displaying a Team discussion item with a reply

    Hi all, We have a SP2013 site with a "What's new" web part on its home page. Amongst other things, it is supposed to display stock-standard "Team discussion" updates. We have the following problems: 1. When a new "Team discussion" topic is created, w

  • I need a text field in a table cell to expand dynamically

    When I say expand I mean the whole cell has to grow as the content is entered into it, not just have a scroll bar present to contain the content, every new line should expand the table cell vertically. I've been looking all over and I can't seem to f

  • SetCurrentRowWithKey(String) not working well over Collections

    Hi.. I'm developing an application using ADF with jsp, struts and toplink. I'm currently having problems with the function setCurrentRowWithKey(String) to try to set the current row of a collection in my DataControl Palette. In my case I have two tab

  • Can't see any of my own music

    Hi, my husband recently got a new computer so I had got his old computer. Unfortunately when I log onto my iTunes account, all I still see is his music and can't see any of my own. How do I fix this so I can start buying more music and transfering th