fix bug in finding expression in string
parent
4da12aac5e
commit
1f308aef41
|
@ -31,15 +31,10 @@ function retval = getStrMoveLeft(str)
|
||||||
% You should have received a copy of the GNU General Public License
|
% You should have received a copy of the GNU General Public License
|
||||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
mathops = '[\+\*\^\-\/]';
|
arithops = '[\+\-]';
|
||||||
|
|
||||||
if str(end) ~= ')'
|
if str(end) ~= ')'
|
||||||
mathidxs = regexp(str, mathops);
|
arithidxs = regexp(str, arithops);
|
||||||
if isempty(mathidxs)
|
|
||||||
retval = str;
|
|
||||||
else
|
|
||||||
retval = str(max(mathidxs)+1:end);
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
closedidxs = strfind(str, ')');
|
closedidxs = strfind(str, ')');
|
||||||
closedidxs = [(length(closedidxs):-1:1)' closedidxs'];
|
closedidxs = [(length(closedidxs):-1:1)' closedidxs'];
|
||||||
|
@ -52,5 +47,11 @@ else
|
||||||
break;
|
break;
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
Loading…
Reference in New Issue