Jump to content

Expressão regular para extrair o texto de uma tabela em HTML


Tiago Salgado

Recommended Posts

Ora bem, podes sempre usar esta função

    Public Function InBetween(ByVal strVariable As String, ByRef str1 As String, ByRef str2 As String, Optional ByRef lngBeginning As Integer = 1) As String
       On Error Resume Next
       Dim iBetween As String
       Dim a As Integer
       Dim b As Integer
       Dim c As Integer

       b = InStr(lngBeginning, strVariable, str1)
       c = InStr(b + Len(str1), strVariable, str2)

       If IsDBNull(b) Or IsDBNull(c) Then
           iBetween = vbNullString
           Return ""
       End If

       strVariable = Replace(strVariable, VB.Right(strVariable, Len(strVariable) - c + 1), vbNullString)

       strVariable = VB.Right(strVariable, Len(strVariable) - InStr(lngBeginning, strVariable, str1, CompareMethod.Text) - Len(str1) + 1)

       Return strVariable
   End Function

Que pro teu caso seria qualquer coisa como

InBetween("80px'>", "</TD")

E obtinhas S825102343

Melhores cumprimentos,João Lopes***Esta mensagem foi escrita ao abrigo do novo Acordo Ortográfico***

Link to comment
Share on other sites

http://msdn2.microsoft.com/en-us/library/hs600312.aspx

VB101SamplesBCL RegularExpressions

"The Dark Side Clouds Everthing. Impossible To See The Future Is."My rig: Intel Core 2 Quad Q9450 | abit IP35P | 4G Kingston 800 Mhz | XFX GeForce 9800 GX2 1G ddr3 | 2X WD5000AAJS 500Gb Sata 2 | PSU 600W || Caixa El-Diablo | Creative XMod

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.