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 452409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:04:10+00:00 2026-05-12T22:04:10+00:00

I’m working on a personal project to auto fill out the USPS Click &

  • 0

I’m working on a personal project to auto fill out the USPS Click & Ship form and then output the Ref# and the Delivery Confirmation #

So far I’ve been able to get the whole process done, but I can’t for the life of me figure out how to pull out the Ref# (which is my order #) and the Delivery Confirmation #

Basically for every package you print a label for the confirmation HTML page comes back with the following in the page.

 <tr class="smTableText">
  <td style="border-top:solid 1px #AAAAAA; padding-bottom:4px;" valign="top">
    <table cellpadding="0" cellspacing="0" border="0" style="margin:7px 0px 0px 5px;">
      <tr> 
       <td valign="top" class="mainText" width=46>1 of 1</td>  
       <td valign="top" width=21><a href="javascript:toggleMoreInfo(0)" tabindex="19"><img src="/cns/images/common/button_plus.gif" height="11" width="11" border="0" hspace="0" vspace="0" id="Img1" style="margin-right:10px;" alt=""></a></td>  
       <td valign="top" width=203><div class="mainText" style="margin-bottom:10px; height:1em; overflow:hidden;" id="Div1">FIRSTLAST NAME<BR>STREET ADDRESS<BR>CITY, STATE  ZIP5-ZIP4<div class="smTableText">email@address.net<BR>Ref#: 100000000<BR></div> </div><div class="smTableText"></div> </td> 
      </tr>
    </table>
  </td> 
  <td style="border-top:solid 1px #AAAAAA; padding-bottom:4px; padding-top:7px;" valign="top" class="smTableText"><div id="Div2" style="margin-left:7px; height:2.4em; overflow:hidden;">&nbsp;Ship Date: 11/17/09<br>&nbsp;Weight: 0lbs 9oz<br>&nbsp;From: 48506<br></div></td>
  <td style="border-top:solid 1px #AAAAAA; padding-bottom:4px; padding-right:15px; padding-top:7px;" valign="top" align="right" class="smTableText"><div class="smTableText" id="Div3" style="height:2.4em; overflow:hidden; margin-bottom:3px;">Priority Mail                      <br>Delivery Confirm.<br></div> <span style="font-weight:bold;" class="smTableText">Label Total</span></td>
  <td style="border-top:solid 1px #AAAAAA; padding-bottom:4px; padding-right:15px; padding-top:7px;" valign="top" align="right" class="smTableText"><div class="smTableText" id="Div4" style="height:2.4em; overflow:hidden; margin-bottom:3px;">$4.80<br>$0.00<br></div><span class="smTableTextbold">$4.80</span></td>
</tr>
<tr class="smTableText"> <td colspan=4 style="height:20px;" valign="top"><div class="mainText" style="margin:0px; padding:4px 8px 0px 8px; display:block; border-top:solid 1px #AAAAAA;">Delivery Confirmation&#153; Label Number: <span class="mainTextbold">0000 1111 2222 3333 4444 55</span></div></td> </tr>

What I need to do is loop through the entire page and find “Ref#: ” capture the next 9 characters.
Then find the next "Label Number: <span class="mainTextbold">" and capture the next 27 characters.
Each pair of Ref#: and Label Number: <span class="mainTextbold"> should be saved to an array.

I’m guessing that regex will probably be my best option for this?
Can anyone provide an example of how this would work. VB.net preferred by C# is ok too.

UPDATE:
As pointed out in the Comments, this is not XML but rather the HTML code from the WebBrowser Control which the page is being displayed on.

I am auto filling in each page, then invoking the click action on the submit button to get to the next page….. Problem is that this last page, the data I need isn’t neatly written around a unique tag to that field for me to pull from…

UPDATE # 2
Alright, using The example given I have come up with the following.
Seems like alot of work to pull out the 2 values. I am guessing there must be a more efficient way of doing it.

   'Sub getdeliverynum(ByVal sText As String)
Sub getdeliverynum()
    Me.MainTabControl.SelectedTab = USPSsiteTAB
    WebBrowser1.Navigate("http://www.vaporstix.com/usps.html")
    While Not WebBrowser1.ReadyState = WebBrowserReadyState.Complete
        Application.DoEvents()
    End While
    Dim input As String = WebBrowser1.DocumentText
    Dim pattern As String = "Ref#: ([^<]+)[\S\s]*?Label Number: <span class=""mainTextbold"">([^<]+)"

    For Each match As Match In Regex.Matches(input, pattern)
        Dim instance As Double
        Dim ref As String = ""
        Dim track As String = ""
        instance = 0
        For Each group As Group In match.Groups
            instance = instance + 1
            If instance = 1 Then
                'do nothing this is the full string.... 
            ElseIf instance = 2 Then
                ref = group.Value
            ElseIf instance = 3 Then
                track = group.Value
            End If
        Next
        'replace with insert to db... this is for testing.
        MsgBox("Ref: " + ref + vbCrLf + "Confirmation: " + track)
    Next

End Sub
  • 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-05-12T22:04:11+00:00Added an answer on May 12, 2026 at 10:04 pm

    To answer the original question, taking into account all the mandatory caveats about “parsing” HTML with regexes, here’s a regex that will do what you want:

    Ref#: (.{9})[\S\s]*?Label Number: <span class="mainTextbold">(.{27})
    

    Backreference \1 will contain the 9 characters after Ref#:, \2 will contain the 27 characters after Label number...

    Alternatively, to make it a bit more robust, you could also use

    Ref#: ([^<]+)[\S\s]*?Label Number: <span class="mainTextbold">([^<]+)
    

    That way, the regex will match any characters except opening angle brackets after the markers. It will lead to a lot more backtracking in case of strings where the regex can’t find a match at all. Depending on the regex engine used, this can be avoided if you use possessive matches:

    Ref#: ([^<]++)[\S\s]*?Label Number: <span class="mainTextbold">([^<]++)
    

    The rationale behind my support of using regexes for this task:

    1. it’s trivial and easy to read/maintain – arguably easier than parsing code
    2. there’s only one match per page, no nesting.
    3. it’s an automatically generated page, so the structure is uniform. If UPS change their page layout, you’d have to adjust the regex, but you’d also have to adjust your xml parser in that case.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string

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.