From 1f308aef41b04d0a369113c724e218031083cc90 Mon Sep 17 00:00:00 2001 From: Houtan Bastani Date: Thu, 2 Nov 2017 15:30:01 +0100 Subject: [PATCH] fix bug in finding expression in string --- matlab/ols/getStrMoveLeft.m | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/matlab/ols/getStrMoveLeft.m b/matlab/ols/getStrMoveLeft.m index 80bc038e6..b96544b05 100644 --- a/matlab/ols/getStrMoveLeft.m +++ b/matlab/ols/getStrMoveLeft.m @@ -31,15 +31,10 @@ function retval = getStrMoveLeft(str) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see . -mathops = '[\+\*\^\-\/]'; +arithops = '[\+\-]'; if str(end) ~= ')' - mathidxs = regexp(str, mathops); - if isempty(mathidxs) - retval = str; - else - retval = str(max(mathidxs)+1:end); - end + arithidxs = regexp(str, arithops); else closedidxs = strfind(str, ')'); closedidxs = [(length(closedidxs):-1:1)' closedidxs']; @@ -52,5 +47,11 @@ else break; end end - retval = str(max(regexp(str(1:openidxs(openparenidx,2)), mathops))+1:closedidxs(end)); + arithidxs = regexp(str(1:openidxs(openparenidx,2)), arithops); +end + +if isempty(arithidxs) + retval = str; +else + retval = str(max(arithidxs)+1:end); end