From b1224f5c5b26d8a281bf4e0c41ba24018f17a258 Mon Sep 17 00:00:00 2001 From: Vivek Teega Date: Sat, 13 Jun 2020 10:48:54 +0530 Subject: [PATCH] Change parsedPlot() to use Regex instead of simple string operations --- index.html | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index 35a3e40..1d5fdb4 100644 --- a/index.html +++ b/index.html @@ -1134,9 +1134,11 @@ function parsePlot(plottext) { - var tstring = plottext.replace(/\s+/g, " "); - tstring = tstring.trim(); - tstring = tstring.split(") -> ("); + var tstring = plottext.replace(/\s+/g, " ") // collapse all whitespace to single whitespace + tstring = tstring.trim(); // trim whitespace from both ends + tstring = tstring.replace(/\)\s*\->\s*\(/g, ")->("); + + tstring = tstring.split(")->("); // split string based on the delimiter if (tstring.length > 0) { if (tstring[0].trim()[0] == "(") { @@ -1161,7 +1163,7 @@ } return tstring; } - + document.getElementById('sectionplotdiv').innerHTML = sectionPlotUI; const section_plot_btn = document.getElementById('section_plot_btn'); section_plot_btn.onclick = function () {