3 Replies Latest reply on Apr 12, 2011 5:48 PM by Brenlei

    Problem with Regular Expression Validator.

    Jay_Ds

      I can't seem to get the regular expression validator to work.  This is flex version 3.2.  I am using a debug version of flash 10 and eclipse 3.4

       

      My regular expression is:

                  private var fileNameRegexp:RegExp = /^[0-9a-zA-Z._\-]+$/g;

       

      I call validate() on a source which is a file name test.tar.gz.  Basically I want simpler file names , though I might try to allow unicode names if I can get this to work. Call is:      var fileNameValidationResult:ValidationResultEvent = fileNameValidator.validate();

       

       

       

      I can step down into the code to the line 357 in RegExpValidator.as which is:

       

                  var result:Object = regExp.exec(String(value));

       

      The regExp variable is:

      regExp    RegExp (@aec93d1)   
          dotall    false   
          extended    false   
          global    false   
          ignoreCase    false   
          lastIndex    0   
          multiline    false   
          source    "/^[0-9a-zA-Z._\\-]+$/g"  

       

      The Value is:

      value    "test.tar.gz"  

       

      I think this should work, but result is returning null.  I have tried it with and without the g flag and without the ^ and $ but I always get a null result

       

      Any idea on what is going on here? I can't figure out what could be going wrong with the validation. Thought I would ask for  help before giving up and parsing the string manually.