fork(1) download
  1. Imports System
  2. Imports System.Text.RegularExpressions
  3.  
  4. Public Class Test
  5. Public Shared Sub Main()
  6. Dim HTMLString As String = "<HTML>" & Environment.NewLine & _
  7. " <body bgcolor=""#FF0000"">" & Environment.NewLine & _
  8. " <span style=""color: #FFA966"" id=""firstspan"">Hello, I am a TeXT. Who are you?</span>" & Environment.NewLine & _
  9. " </body>" & Environment.NewLine & _
  10. "</HTML>"
  11.  
  12. Console.WriteLine("--- Input ---" & Environment.NewLine & HTMLString & Environment.NewLine)
  13. Console.WriteLine("--- Match ---" & Environment.NewLine & FindTextInSpan(HTMLString, "firstspan", "text"))
  14. End Sub
  15.  
  16. Public Shared Function FindTextInSpan(ByVal HTML As String, ByVal SpanId As String, ByVal LookFor As String) As String
  17. Dim m As Match = Regex.Match(HTML, "(?<=<span.+id=""" & SpanId & """.*>.*)" & LookFor & "(?=.*<\/span>)", RegexOptions.IgnoreCase)
  18. Return If(m IsNot Nothing, m.Value, "")
  19. End Function
  20. End Class
Success #stdin #stdout 0.08s 24600KB
stdin
Standard input is empty
stdout
--- Input ---
<HTML>
    <body bgcolor="#FF0000">
        <span style="color: #FFA966" id="firstspan">Hello, I am a TeXT. Who are you?</span>
    </body>
</HTML>

--- Match ---
TeXT