Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8043361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:52:41+00:00 2026-06-05T04:52:41+00:00

i’m using a vbscript with regex to parse a file so i can convert

  • 0

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:

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

I’m basing myself on this answer.

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.

The lat1.txt file is a simple txt file with the following lines:

41d3'40.313"N  
38d42'29.295"N  
41d28'13.616"N  

The first to echo statements are working… the problem is in the last one.

Can somebody help me?

Thanks in advance,
Cláudio

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T04:52:42+00:00Added an answer on June 5, 2026 at 4:52 am

    It is your pattern, replace it with

    oRE.Pattern = "^(\d+)d(\d+)\'(\d+\.\d+)""(N|W) *$" 
    

    gives following, the output of the seconds is not correct on my system, but that could be regional settings

    41d3'40.313"N   
    38d42'29.295"N   
    41d28'13.616"N   
    
    |LoLa |Degrees    |Minutes    |Seconds        |
    |N    |      41,00|       3,00|  40.313,000000|
    |N    |      38,00|      42,00|  29.295,000000|
    |N    |      41,00|      28,00|  13.616,000000|
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.