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!
8 2316
i would do something silly like this -
dim example
-
example = "<p class=""header"" style=""margin-top:35px; margin-bottom:0px;"">text I want to caputre</p>"
-
example = split(example, "<")(1)
-
example=split(example, ">")(1)
-
response.write example
-
- Edit: but as I can see your looking for something more complex.
i would do something silly like this -
dim example
-
example = "<p class=""header"" style=""margin-top:35px; margin-bottom:0px;"">text I want to caputre</p>"
-
example = split(example, "<")(1)
-
example=split(example, ">")(1)
-
response.write example
-
- 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.
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
.
.
.
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.
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...
i'm not a mod in VB i'm sure someone will remove it.
I am not much of a guru with regex, but try this one. - $matches = array();
-
$pattern1 = '/(\<p)(.+?)(\<\/p\>)/i';
-
preg_match($pattern1,$tekst,$matches);
-
echo $matches[0];
I know it is PHP, but you could rework it.
Ronald :cool:
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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;
}
|
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...
|
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...
|
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...
|
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...
|
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...
|
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
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
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...
|
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,...
|
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...
|
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...
|
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...
|
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...
| |