0 Replies Latest reply on Apr 22, 2011 8:46 AM by adi_shkhan

    RegExp giving unexpected result

    adi_shkhan

      Hello Friends,

      Facing problem with regexp pattern

      A string not matching regex pattern is also returned as proper match...

      Here's  what I am trying to do :

       

       

      <mx:ArrayCollection id="names">
              <mx:String>RS2SAN11030001000123</mx:String>
              <mx:String>RS2SAN11020001000132</mx:String>
              <mx:String>RS2SAN11030001000165</mx:String>
              <mx:String>RS2SAN11030001000143</mx:String>
              <mx:String>ABRS2SAN11020001000143</mx:String>

         </mx:ArrayCollection>

       

      In a script tag, inside a function I write this :

       

      var re:RegExp=/^RS2SAN1103\d{6}/;
                          var i:int=0;
                          var ret:Object;
                          for(i=0;i<names.length;i++)
                          {
                              ret=re.exec(names.getItemAt(i).toString())
                              if(ret==null)
                                  Alert.show(names.getItemAt(i)+"no match");
                              else
                              {
                                  Alert.show(names.getItemAt(i)+"match"); //this is executed even for string  "RS2SAN11020001000132"
                          
                              }
                          }