By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,984 Members | 2,832 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,984 IT Pros & Developers. It's quick & easy.

Question: Regex in VB 5

P: 8
I just need to capture and display text portion of HTML page.

example is:
<p class="header" style="margin-top:35px; margin-bottom:0px;">
text I want to caputre</p>

I have a few hundred pages constructed this way.
Obviously my site runs vbscript version 5 and does not support submatches nor expression that I wanted to use. (no. I can't upgrade)

How would I just capture text portion of this tag and display?
I was thinking something like this but I do not want <TAG> to appear

Expand|Select|Wrap|Line Numbers
  1. Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
  2. Set objTextFile = objFSO.OpenTextFile(Server.MapPath(URLString), ForReading)
  3. strContent = objTextFile.ReadAll
  4. objTextFile.Close
  5. set objTextFile = nothing
  6. set objFSO = nothing
  8. Set objRegExp = New RegExp
  9. with objRegExp
  10. .Pattern = "<p[^>]*header.*>([^<]+|.*)?<\/p>"
  11. .IgnoreCase = True
  12. end with
  13. If colMatches.Count > 0 Then
  14. Response.Write "Test result: " & colMatches.item(0).value <<<<<<<<<<<<<<<<<<<<< HERE
  15. Response.Write colMatches.Count & " matches!"
  17. For Each strMatch in colMatches
  18. Response.Write strMatch.Firstindex & strMatch.Value
  19. Next
  20. Else
  21. Response.Write "string not found"
  22. End if
  23. Set objRegExp = nothing
Better pattern would be appreciated but mostly I would like to know how I can only display text portion within the tag.

If it were vb 5.5 +
I would do
.Pattern = "<p[\s]+[^>]*?class[\s]?=[\s""\']+blackheader[\s""\']+.*?>([^<]+|.*?)?<\/p>"
Set strMatch = colMatches(0)
If strMatch.SubMatches.Count >=1 Then
wscript.echo strMatch.SubMatches(0)
End If

But again I don't know what to do here...

Thank your help!
Apr 16 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.