5 Replies Latest reply on Nov 14, 2006 2:47 PM by cyprianpl

    RegExpValidator broken?

    HowlerMonkey
      I'm trying to perform a simple validation for an IP addresses in a TextField. It fails, so I've simplified it to identify where it breaks:

      expression="\d{1,3}\.\d{1,3}"

      The test above should validate 123.123, but it fails.

      expression="\d{1,3}" // works for 123
      expression="\d{1,3}\." // works for 123.
      expression="\d{1,3}\.\d{1,3}" // fails for 123.123

      Thoughts on why this simple regex isn't working in RegExpValidator?

      Thanks
        • 1. Re: RegExpValidator broken?
          cyprianpl
          I've also got problems with RegExpValidator.
          This expression doesn't seem to work:
          expression="^[a-z]+[a-z0-9_]{2,}$"
          or
          expression="/^[a-z]+[a-z0-9_]{2,}$/"
          It seans that the {n,m} thing is broken or something... :/
          • 2. RegExpValidator broken?
            dimival Level 1
            Howler Monkey:
            Can you paste your validator code here? i tried the one you pasted here and it works.
            • 3. Re: RegExpValidator broken?
              cyprianpl Level 1
              Actually I've got compiler errors in Flex Builder 2 Beta for Mac OS X for this expression [it complains about curly braces].
              Please try out this code:

              <?xml version="1.0" encoding="utf-8"?>
              <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="vertical">
              <mx:TextInput id="field" width="100" />
              <mx:TextInput id="dummy" width="100" />
              <mx:RegExpValidator id="regExpV" source="{field}" property="text"
              expression="^[a-z]+[a-z0-9_]{2,}$" listener="{field}" trigger="{field}" />
              </mx:Application>

              I've got following erros:
              #1083: Syntax error: rightparen is unexpected
              #1083: Syntax error: rightparen is unexpected
              #1084: Syntax error: expecting rightparen before semicolon
              #1084: Syntax error: expecting rightparen before semicolon

              I think I don't get regexp in RegExpValidator.
              I'd like to validate user input against a pattern like: a character at the beginning and then at least two other characters from declared range ([a-z0-9_]). That's all...
              • 4. Re: RegExpValidator broken?
                dimival Level 1
                quote:

                Originally posted by: cyprianpl
                Actually I've got compiler errors in Flex Builder 2 Beta for Mac OS X for this expression [it complains about curly braces].
                Please try out this code:

                <?xml version="1.0" encoding="utf-8"?>
                <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="vertical">
                <mx:TextInput id="field" width="100" />
                <mx:TextInput id="dummy" width="100" />
                <mx:RegExpValidator id="regExpV" source="{field}" property="text"
                expression="^[a-z]+[a-z0-9_]{2,}$" listener="{field}" trigger="{field}" />
                </mx:Application>

                I've got following erros:
                #1083: Syntax error: rightparen is unexpected
                #1083: Syntax error: rightparen is unexpected
                #1084: Syntax error: expecting rightparen before semicolon
                #1084: Syntax error: expecting rightparen before semicolon

                I think I don't get regexp in RegExpValidator.
                I'd like to validate user input against a pattern like: a character at the beginning and then at least two other characters from declared range ([a-z0-9_]). That's all...



                Try this:

                expression="{'^[a-z]+[a-z0-9_]{2,}$'}"

                the expression property receives a string, so make sure you pass a string like in the code above.
                • 5. Re: RegExpValidator broken?
                  cyprianpl Level 1
                  Thanks dimival, it works!