From 1261e48bcc12d2226f710ab3bbd66ec4af325a5c 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 ad2cb449a26..afa8473ec3f 100644 --- a/includes/shipping/flat-rate/class-wc-shipping-flat-rate.php +++ b/includes/shipping/flat-rate/class-wc-shipping-flat-rate.php @@ -256,7 +256,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];