Caroline Jen wrote:

If we require a file name submitted by users must be
less than 40 characters, not have space and have a
single 3 character extension (for example: .doc, .txt,
.pdf)

To set 40 characters limit, we can do:

<field
   property="filename"
   depends="required,maxlength">
      <arg0 key="select.filename"/>
      <arg1 name="maxlength" key="${var:maxlength}"
resource="false"/>
         <var>
            <var-name>maxlength</var-name>
            <var-value>40</var-value>
         </var>
</field>

I think the 3 characters extension may be something
similar to ^\d{3}\d*$ (I can be wrong).  And how do we
set the 'no space' constraint?


I think you need to read up on regular expressions a bit before asking here. Try out:


http://www.regular-expressions.info/reference.html

The answer to your question depends on what characters you want to allow to be typed in as well.

Off the top of my head, something like this (totally untested):

^\S+\.\S{3}$

would work, but it allows ANY non-whitespace character to be typed in - this would include slashes, number signs, and other "wacky" characters that aren't good for filenames. This regexp roughly translates into:

any non-whitespace character 1 or more times, then a period, than any non-whitespace character exactly 3 times


The regexp you suggested translates into this: digit character 3 times, then digit character 0 or more times


Like I said, you need to read up a little bit more, as this is not really a regexp help center :)



Matt



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to