4 Replies Latest reply on Jun 17, 2008 6:35 AM by VarioPegged

    Help with RegEx and Textinput

    Mike Bauer
      I have the following method:
      public function handleKeyPress(event:KeyboardEvent):void {
      //trace("Key pressed: "+event.keyCode+","+event.charCode);
      var testTest:String = cComponent.cInput.text + String.fromCharCode(event.keyCode);
      trace("Text tested: \""+testTest+"\"");

      // See if the user typed '/' followed by a number and a space
      if(testTest.match(new RegExp("\/[0-9]*\s"))) {
      // User typed '/### '
      // TODO: Get bpname and do something here...
      cComponent.cInput.text="";
      event.stopImmediatePropagation();
      }
      }

      Basically, I need to match on the pattern "/### ", where ### is any series of numbers, do something, then clear the TextInput, but I can't seem to get the RegEx right. I have tried several different ones, including '\/\d*\s' and '\/[0-9]* ', but nothing seems to work.

      On top of this, the call to cComponent.cInput.text="" doesn't wipe the value of the TextInput field either.

      Can someone point me in the right direction?