From 0fd11ad509ae5708731b3cc85f4ad722f57580fa Mon Sep 17 00:00:00 2001 From: Patrick Rauland Date: Mon, 24 Feb 2014 11:40:26 -0600 Subject: [PATCH] commenting regex in flat rate shipping --- .../shipping/flat-rate/class-wc-shipping-flat-rate.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/includes/shipping/flat-rate/class-wc-shipping-flat-rate.php b/includes/shipping/flat-rate/class-wc-shipping-flat-rate.php index 9be14d270ae..e429628d1bb 100644 --- a/includes/shipping/flat-rate/class-wc-shipping-flat-rate.php +++ b/includes/shipping/flat-rate/class-wc-shipping-flat-rate.php @@ -249,7 +249,15 @@ class WC_Shipping_Flat_Rate extends WC_Shipping_Method { $extra_rate['label'] = $this_option[0]; $this_cost = $this_option[1]; - if (preg_match('/(\d+\.?\d*)\s*(\+|-)\s*(\d+\.?\d*)\%/', $this_cost, $this_cost_matches)) { + $pattern = + '/' . // start regex + '(\d+\.?\d*)' . // capture digits, optionally capture a `.` and more digits + '\s*' . // match whitespace + '(\+|-)' . // capture the operand + '\s*'. // match whitespace + '(\d+\.?\d*)'. // capture digits, optionally capture a `.` and more digits + '\%/'; // match the percent sign & end regex + if ( preg_match( $pattern, $this_cost, $this_cost_matches ) ) { $this_cost_mathop = $this_cost_matches[2]; $this_cost_percents = $this_cost_matches[3] / 100; $this_cost = $this_cost_matches[1];