title: VBScript regex cycle
body: <p>i'm using a vbscript with regex to parse a file so i can convert a bunch of coordinates. This is the current code i have:</p>
  
  <pre><code>Class cFormat
  Private m_oSB
  Private Sub Class_Initialize()
    Set m_oSB = CreateObject("System.Text.StringBuilder")
  End Sub ' Class_Initialize
  
  Public Function formatOne(sFmt, vElm)
   m_oSB.AppendFormat sFmt, vElm
    formatOne = m_oSB.ToString()
    m_oSB.Length = 0
  End Function ' formatOne
  
  Public Function formatArray(sFmt, aElms)
    m_oSB.AppendFormat_4 sFmt, (aElms)
    formatArray = m_oSB.ToString()
    m_oSB.Length = 0
  End Function ' formatArray
  
  End Class ' cFormat
  
  Dim goFS : Set goFS = CreateObject("Scripting.FileSystemObject")
  
  Dim oFmt : Set oFmt = New cFormat
  
  Dim oRE  : Set oRE  = New RegExp
  oRE.Global    = True
  oRE.Multiline = True
  '                 0     1        2        3
  oRE.Pattern = "^(\d+)d(\d+)'(\d+\.\d+)""([WN])$"
  
  Dim sALL : sALL = goFS.OpenTextFile("C:\...\lat1.txt").ReadAll()
  WScript.Echo sALL
  
  WScript.Echo oFmt.formatArray( _
    "|{0,-5}|{1,-11}|{2,-11}|{3,-15}|" _
  , Array("LoLa", "Degrees", "Minutes", "Seconds") _
  )
  
   Dim oMTS : Set oMTS = oRE.Execute(sALL)
  
  Dim oMT
  For Each oMT In oMTS
    Dim sLoLa    : sLoLa    =      oMT.SubMatches(3)
    Dim nDegrees : nDegrees = CDbl(oMT.SubMatches(0))
    Dim nMinutes : nMinutes = CDbl(oMT.SubMatches(1))
    Dim nSeconds : nSeconds = CDbl(oMT.SubMatches(2))
  
  WScript.Echo oFmt.formatArray( _
        "|{0,-5}|{1,11:N2}|{2,11:N2}|{3,15:N6}|" _
      , Array(sLoLa, nDegrees, nMinutes, nSeconds) _
  )
  Next
  </code></pre>
  
  <p>I'm basing myself on this <a href="https://stackoverflow.com/questions/10739339/convert-latitude-longitude-to-decimal-degrees">answer</a>.</p>
  
  <p>The problem i'm having is that, all the variables in the cycle are empty, so in the last echo i don't get nothing. I can't seem to identify the problem, is the regular expression? the cycle? I really don't know.</p>
  
  <p>The lat1.txt file is a simple txt file with the following lines:</p>
  
  <pre><code>41d3'40.313"N  
  38d42'29.295"N  
  41d28'13.616"N  
  </code></pre>
  
  <p>The first to echo statements are working... the problem is in the last one.</p>
  
  <p>Can somebody help me? </p>
  
  <p>Thanks in advance,
  Cláudio</p>