1 Reply Latest reply on May 18, 2010 1:55 PM by GordonSmith

    RegExp with Variables

    andrewthorp Level 1

      How can I perform a calculation on variables of a regular expression?

       

      This should clear up what I am trying to do:

       

      pattern = /SIZE=\"(.*?)\"/g;

      str = str.replace(pattern, "style=\"font-size: $1px; line-height: $1px;\"" );

       

      line-height: $1px;

       

      is not correct, but I need to find some way to turn it into

       

      line-height: ($1*1.4)px;

       

      How can I perform math on the string I find as a variable?