Skip to main content
A bug
Source Link
Mark Hurd
  • 336
  • 3
  • 9

As mentioned in the comments, note that this is "reviewing" the code in the self-answer:

The Replace calls effectively implementing the missing RemoveFrom method isn't needed here. You could add extra brackets to the RegEx, and just extract the captures you want, but here you know the position and length of what you're skipping, so just use Mid$. I.e. this:

 If Not thisMatch.SubMatches(1) = vbEmpty Then specifier.Alignment = CInt(Replace(CStr(thisMatch.SubMatches(1)), ",", vbNullString)) If Not thisMatch.SubMatches(2) = vbEmpty Then specifier.identifier = Left(Replace(CStr(thisMatch.SubMatches(2)), ":", vbNullString), 1) specifier.CustomSpecifier = Replace(CStr(thisMatch.SubMatches(2)), ":" & specifier.identifier, vbNullString) End If 

becomes this:

 If Not thisMatch.SubMatches(1) = vbEmpty Then specifier.Alignment = CInt(Mid$(CStr(thisMatch.SubMatches(1)), 2)) If Not thisMatch.SubMatches(2) = vbEmpty Then specifier.identifier = Mid$(CStr(thisMatch.SubMatches(2)), 2, 1) specifier.CustomSpecifier = Mid$(CStr(thisMatch.SubMatches(2)), 3) End If 

BUG

To avoid counting wrong for the pedantic case of "{2}{11}{1}...", initialise csvIndices to "," and search for "," & specifier.Index & ",".

As mentioned in the comments, note that this is "reviewing" the code in the self-answer:

The Replace calls effectively implementing the missing RemoveFrom method isn't needed here. You could add extra brackets to the RegEx, and just extract the captures you want, but here you know the position and length of what you're skipping, so just use Mid$. I.e. this:

 If Not thisMatch.SubMatches(1) = vbEmpty Then specifier.Alignment = CInt(Replace(CStr(thisMatch.SubMatches(1)), ",", vbNullString)) If Not thisMatch.SubMatches(2) = vbEmpty Then specifier.identifier = Left(Replace(CStr(thisMatch.SubMatches(2)), ":", vbNullString), 1) specifier.CustomSpecifier = Replace(CStr(thisMatch.SubMatches(2)), ":" & specifier.identifier, vbNullString) End If 

becomes this:

 If Not thisMatch.SubMatches(1) = vbEmpty Then specifier.Alignment = CInt(Mid$(CStr(thisMatch.SubMatches(1)), 2)) If Not thisMatch.SubMatches(2) = vbEmpty Then specifier.identifier = Mid$(CStr(thisMatch.SubMatches(2)), 2, 1) specifier.CustomSpecifier = Mid$(CStr(thisMatch.SubMatches(2)), 3) End If 

As mentioned in the comments, note that this is "reviewing" the code in the self-answer:

The Replace calls effectively implementing the missing RemoveFrom method isn't needed here. You could add extra brackets to the RegEx, and just extract the captures you want, but here you know the position and length of what you're skipping, so just use Mid$. I.e. this:

 If Not thisMatch.SubMatches(1) = vbEmpty Then specifier.Alignment = CInt(Replace(CStr(thisMatch.SubMatches(1)), ",", vbNullString)) If Not thisMatch.SubMatches(2) = vbEmpty Then specifier.identifier = Left(Replace(CStr(thisMatch.SubMatches(2)), ":", vbNullString), 1) specifier.CustomSpecifier = Replace(CStr(thisMatch.SubMatches(2)), ":" & specifier.identifier, vbNullString) End If 

becomes this:

 If Not thisMatch.SubMatches(1) = vbEmpty Then specifier.Alignment = CInt(Mid$(CStr(thisMatch.SubMatches(1)), 2)) If Not thisMatch.SubMatches(2) = vbEmpty Then specifier.identifier = Mid$(CStr(thisMatch.SubMatches(2)), 2, 1) specifier.CustomSpecifier = Mid$(CStr(thisMatch.SubMatches(2)), 3) End If 

BUG

To avoid counting wrong for the pedantic case of "{2}{11}{1}...", initialise csvIndices to "," and search for "," & specifier.Index & ",".

Source Link
Mark Hurd
  • 336
  • 3
  • 9

As mentioned in the comments, note that this is "reviewing" the code in the self-answer:

The Replace calls effectively implementing the missing RemoveFrom method isn't needed here. You could add extra brackets to the RegEx, and just extract the captures you want, but here you know the position and length of what you're skipping, so just use Mid$. I.e. this:

 If Not thisMatch.SubMatches(1) = vbEmpty Then specifier.Alignment = CInt(Replace(CStr(thisMatch.SubMatches(1)), ",", vbNullString)) If Not thisMatch.SubMatches(2) = vbEmpty Then specifier.identifier = Left(Replace(CStr(thisMatch.SubMatches(2)), ":", vbNullString), 1) specifier.CustomSpecifier = Replace(CStr(thisMatch.SubMatches(2)), ":" & specifier.identifier, vbNullString) End If 

becomes this:

 If Not thisMatch.SubMatches(1) = vbEmpty Then specifier.Alignment = CInt(Mid$(CStr(thisMatch.SubMatches(1)), 2)) If Not thisMatch.SubMatches(2) = vbEmpty Then specifier.identifier = Mid$(CStr(thisMatch.SubMatches(2)), 2, 1) specifier.CustomSpecifier = Mid$(CStr(thisMatch.SubMatches(2)), 3) End If