0 Replies Latest reply on Feb 13, 2014 3:00 AM by PoornimaBS

    Regular expression in exact match

    PoornimaBS

      Hi,

       

      Please let me know how do i find an exact match within a string using Regular expression,

       

      var str1:String = "s1 + s2 + sf_s1 + s1 - s2";

      var replceableStr:String = "s1";

      var reggular:RegExp = /\s+(s1)\s+/gi;

      var str2:String;

      str2 = str1.replace(reggular,"format");

       

       

       

       

       

       

      i want only s1 to be replaced with format but sf_s1 should not be replaced, please let me know which Reg exp to use

       

      Expected output: format + s2 +sf_s1 + format -s2