From c5513d3a6575216f559136c56878d6ee7b5419fc Mon Sep 17 00:00:00 2001 From: adam Date: Fri, 9 Oct 2009 09:33:41 +0000 Subject: [PATCH] Replace a fix by another fix ... --- src/KERNEL_PY/salome_notebook.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/KERNEL_PY/salome_notebook.py b/src/KERNEL_PY/salome_notebook.py index 48404bff9..630163e8a 100644 --- a/src/KERNEL_PY/salome_notebook.py +++ b/src/KERNEL_PY/salome_notebook.py @@ -110,14 +110,17 @@ class NoteBook: aResult_orig = aResult l = self.myStudy.GetVariableNames() l.remove(variableName) + # -- + # To avoid the smallest strings to be replaced first, + # the list is sorted by decreasing lengths + # -- + l.sort(key=str.__len__) + l.reverse() for name in l: - val = self.get(name) - import re - while 1: - m = re.search(r"\b(%s)\b"%name, aResult) - if not m: break - aResult = aResult[:m.start()] + "%s"%(val) + aResult[m.end():] - pass + if aResult.find(name) >= 0: + val = self.get(name) + aResult = aResult.replace(name, "%s"%(val)) + pass pass try: aResult = eval(aResult) -- 2.39.2