473,398 Members | 2,212 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

regex submatch (copied to vb for more support)

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

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

Obviously my site runs vbscript version 5 and does not support submatches nor expression that I wanted to use. (no. I can't upgrade)

Anyway.
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

Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile(Server.MapPath(URLString), ForReading)
strContent = objTextFile.ReadAll
objTextFile.Close
set objTextFile = nothing
set objFSO = nothing

Set objRegExp = New RegExp
with objRegExp
.Pattern = "<p[^>]*header.*>([^<]+|.*)?<\/p>"
.IgnoreCase = True
end with
If colMatches.Count > 0 Then
Response.Write "Test result: " & colMatches.item(0).value <<<<<<<<<<<<<<<<<<<<< how can I just get value only within ()?
Response.Write colMatches.Count & " matches!"

For Each strMatch in colMatches
Response.Write strMatch.Firstindex & strMatch.Value
Next
Else
Response.Write "string not found"
End if
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.

Thank your help!
Apr 16 '07 #1
5 1755
iam_clint
1,208 Expert 1GB
i would do something silly like this
Expand|Select|Wrap|Line Numbers
  1. dim example
  2. example = "<p class=""header"" style=""margin-top:35px; margin-bottom:0px;"">text I want to caputre</p>"
  3. example = split(example, "<")(1)
  4. example=split(example, ">")(1) 
  5. response.write example
  6.  
- Edit: but as I can see your looking for something more complex.
Apr 16 '07 #2
iam_clint
1,208 Expert 1GB
i'm not great at regular expressions but there is a program i know of to help build them its called the regulator, its free and heres a link.

http://sourceforge.net/projects/regulator/
Apr 16 '07 #3
i would do something silly like this
Expand|Select|Wrap|Line Numbers
  1. dim example
  2. example = "<p class=""header"" style=""margin-top:35px; margin-bottom:0px;"">text I want to caputre</p>"
  3. example = split(example, "<")(1)
  4. example=split(example, ">")(1) 
  5. response.write example
  6.  
- Edit: but as I can see your looking for something more complex.
yes, I would not use regex if text in var example is consistent. I have a few hundred pages constructed this way.
All contains form of this tag.
I do need to get the text out of each pages.
Apr 16 '07 #4
i'm not great at regular expressions but there is a program i know of to help build them its called the regulator, its free and heres a link.

http://sourceforge.net/projects/regulator/
Problem here is that I can do this easy in vb 5.5 or later using submatch.. and use it as follows, but again this problem comes with vb 5 regex engine.
.
.

.Pattern = "<p[\s]+[^>]*?class[\s]?=[\s""\']+blackheader[\s""\']+.*?>([^<]+|.*?)?<\/p>"
.
.
.
If strMatch.SubMatches.Count >=1 Then
Response.Write strMatch.SubMatches(0)
End If
.
.
.
Apr 16 '07 #5
iam_clint
1,208 Expert 1GB
darn man you have me stumped maybe someone more familiar with regular expressions and vb5 will figure it out i'll have some people come look at the post.


also i'll copy this into visual basic help, asp and vb are so close maybe they will have an answer for you.
Apr 16 '07 #6

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

Similar topics

75
by: Xah Lee | last post by:
http://python.org/doc/2.4.1/lib/module-re.html http://python.org/doc/2.4.1/lib/node114.html --------- QUOTE The module defines several functions, constants, and an exception. Some of the...
3
by: DrewM | last post by:
I'm sure this isn't difficult, but it's Friday afternoon (!). I'm trying to use a regular expression to match html tags in a string and convert them to lower case. It's the RegExp object that I'm...
3
by: Jon Maz | last post by:
Hi All, Am getting frustrated trying to port the following (pretty simple) function to CSharp. The problem is that I'm lousy at Regular Expressions.... //from...
17
by: clintonG | last post by:
I'm using an .aspx tool I found at but as nice as the interface is I think I need to consider using others. Some can generate C# I understand. Your preferences please... <%= Clinton Gallagher ...
7
by: Aek | last post by:
Hi everyone, I am trying to construct a regular expression and format string to use with a boost::regex_replace() In my file the sample text is: // .fx shader file FLOAT JOE 3545f; FLOAT...
4
by: DSmith1974 | last post by:
Are lookarounds supported in the boost regex lib? In my VS6 project using boost 1.32.0 I can declare a regex as.. <code_snippet> std::wstring wstrFilename = L"01_BAR08"; boost::wregex...
8
by: mossimokim | last post by:
I just need to capture and display text portion of HTML page. <p class="header" style="margin-top:35px; margin-bottom:0px;"> text I want to caputre</p> Obviously my site runs vbscript version...
4
by: Henrik Dahl | last post by:
Hello! In my application I have a need for using a regular expression now and then. Often the same regular expression must be used multiple times. For performance reasons I use the...
5
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
I have a .Net web service that converts the MODCA files to tif or png file format. This web service runs on a 2003 server. This web service first copies the MODCA file to be converted to a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.