From 4115a98ecb90d62e97e72cecad50b0a1f72840bb Mon Sep 17 00:00:00 2001 From: Bohung Date: Mon, 7 Feb 2022 18:30:42 +0800 Subject: [PATCH] Fix bug. --- app/models/cancerpredictfields.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/cancerpredictfields.rb b/app/models/cancerpredictfields.rb index 3f6b76f..8d6e75b 100644 --- a/app/models/cancerpredictfields.rb +++ b/app/models/cancerpredictfields.rb @@ -331,7 +331,7 @@ class Cancerpredictfields js_code += "\n #{self.tmp_hidden_variables_for_js}" formula = text_to_math(self.prediction_formula) self.all_variables.each do |k| - formula = formula.gsub(/#{k}?(-|\+|\*|\s|\=)/){ "result[\"#{k.strip}\"]#{$1}" } + formula = formula.gsub(/(\A|[^\w])#{k}($|[^\w])/){|f| "#{$1}result[\"#{k.strip}\"]#{$2}" } end formula_variables = self.tmp_lpv_variables.map{|v| v} js_code = "\n function calculate_first_lpv(result_json){