473,397 Members | 2,028 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,397 software developers and data experts.

regex submatch

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
8 2316
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
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.

I really appreciate it... I am under the time pressure.. I googled and looked at vb reference but being stressed out.

by the way.. I posted on vb forum... apologize for dupe.. it doesn't allow me to delete...
Apr 16 '07 #7
iam_clint
1,208 Expert 1GB
i'm not a mod in VB i'm sure someone will remove it.
Apr 16 '07 #8
ronverdonk
4,258 Expert 4TB
I am not much of a guru with regex, but try this one.
Expand|Select|Wrap|Line Numbers
  1. $matches = array();
  2. $pattern1 = '/(\<p)(.+?)(\<\/p\>)/i';
  3. preg_match($pattern1,$tekst,$matches);
  4. echo $matches[0]; 
I know it is PHP, but you could rework it.

Ronald :cool:
Apr 16 '07 #9

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

Similar topics

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...
9
by: Tim Conner | last post by:
Is there a way to write a faster function ? public static bool IsNumber( char Value ) { if (Regex.IsMatch( Value.ToString(), @"^+$" )) { return true; } else return false; }
6
by: Extremest | last post by:
I have a huge regex setup going on. If I don't do each one by itself instead of all in one it won't work for. Also would like to know if there is a faster way tried to use string.replace with all...
7
by: Extremest | last post by:
I am using this regex. static Regex paranthesis = new Regex("(\\d*/\\d*)", RegexOptions.IgnoreCase); it should find everything between parenthesis that have some numbers onyl then a forward...
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...
3
by: aspineux | last post by:
My goal is to write a parser for these imaginary string from the SMTP protocol, regarding RFC 821 and 1869. I'm a little flexible with the BNF from these RFC :-) Any comment ? tests= def...
5
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...
15
by: morleyc | last post by:
Hi, i would like to remove a number of characters from my string (\t \r \n which are throughout the string), i know regex can do this but i have no idea how. Any pointers much appreciated. Chris
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.