Index: trunk/MagicSoft/Mars/mdata/MDataPhrase.cc
===================================================================
--- trunk/MagicSoft/Mars/mdata/MDataPhrase.cc	(revision 8315)
+++ trunk/MagicSoft/Mars/mdata/MDataPhrase.cc	(revision 8635)
@@ -138,11 +138,14 @@
 Int_t MDataPhrase::CheckForVariable(const TString &phrase, Int_t idx)
 {
-    TPRegexp reg(Form("\\w\\[%d\\]\\w", idx));
-
     TString mods;
     TArrayI pos;
 
-    while (reg.Match(phrase, mods, 0, 130, &pos))
-    {
+    while (1)
+    {
+        // \\W: matches any non-word character [^a-zA-Z_0-9]
+        TPRegexp reg(Form("\\W\\[0*%d\\]\\W", idx));
+        if (reg.Match(phrase, mods, 0, 130, &pos)==0)
+            break;
+
         // [idx] already existing. Add a corresponding MDataValue
         fMembers.AddLast(new MDataValue(0, idx));
@@ -158,5 +161,5 @@
 // with %s being the expression) in the string phrase by [idx].
 //
-// The length of [idx]9 is returned.
+// The length of [idx] is returned.
 //
 Int_t MDataPhrase::Substitute(TString &phrase, const TString &expr, Int_t idx) const
@@ -247,4 +250,5 @@
     // numbers can contain a dot the result has to
     // be checked carefully
+    // \\w: matches any word character [a-zA-Z_0-9]
     TPRegexp reg = TPRegexp("\\w+[.]\\w+");
     TPRegexp ishex("^0x[[:xdigit:]]+$");
@@ -313,4 +317,13 @@
         // Step forward to the next argument
         idx++;
+    }
+
+    // Now we have to check if there are additional indices [idx]
+    // This is mainly important if the rule has indices only!
+    while (1)
+    {
+        const Int_t newidx = CheckForVariable(phrase, idx);
+        if (newidx == idx)
+            break;
     }
 
@@ -578,4 +591,18 @@
     return rule;
 }
+
+// --------------------------------------------------------------------------
+//
+// This returns the rule as seen/interpreted by the TFormula. Mainly
+// for debugging purposes
+//
+TString MDataPhrase::GetRuleRaw() const
+{
+    if (!fFormula)
+        return "<empty>";
+
+    return fFormula->GetExpFormula();
+}
+
 /*
 // --------------------------------------------------------------------------
Index: trunk/MagicSoft/Mars/mdata/MDataPhrase.h
===================================================================
--- trunk/MagicSoft/Mars/mdata/MDataPhrase.h	(revision 8315)
+++ trunk/MagicSoft/Mars/mdata/MDataPhrase.h	(revision 8635)
@@ -48,4 +48,5 @@
     Double_t GetValue() const;
     TString  GetRule() const;
+    TString  GetRuleRaw() const;
     Bool_t   PreProcess(const MParList *plist);
     //    void Print(Option_t *opt = "") const;
