473,837 Members | 1,603 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Repost: Can anyone help with this Regex problem?

I'm trying to figure out a regular expression that will match the
innermost tag and the contents in between. Specifically, the string
that I am attempting to match looks as follows:

....<table>...< table>...>Final <...</table>...</table>...

I want to match: <table>...>Fina l<...</table> from this example.

The string could also, of course, look like the following:

....<table>...< table>...</table>...<table >...>Final<.. .</table>...<table >...</table>...</table>...

I am looking for the innermost <table> </table> tags that have a
specific string in that table - in this case >Final<.

Any help would be greatly appreciated. If there are other newsgroups
dedicated to regular expressions I would be happy to redirect my post
there.

Thanks in advance,
Greg
Nov 20 '05 #1
5 1662
Hi Greg,

Why are you not using mshtml and process the text directly?

Cor
Nov 20 '05 #2

Try using or modifying the following expression:

<table>(?><tabl e>(?<level>)|(? <contents-level>)</table>|.)*(?(le vel)(?!))</t
able>

This will give you the contents of the innermost table tags in the Captures
collection of the named group "contents". You could then just iterate
through them and find the ones that contain the string you are looking for.
You could probably modify this expression to match exactly what you want
without this step.
Hope this helps,

Brian Davis
http://www.knowdotnet.com

"Greg Vereschagin" <gr****@optonli ne.net> wrote in message
news:ko******** *************** *********@4ax.c om...
I'm trying to figure out a regular expression that will match the
innermost tag and the contents in between. Specifically, the string
that I am attempting to match looks as follows:

...<table>...<t able>...>Final< ...</table>...</table>...

I want to match: <table>...>Fina l<...</table> from this example.

The string could also, of course, look like the following:

....<table>...< table>...</table>...<table >...>Final<.. .</table>...<table >...<
/table>...</table>...
I am looking for the innermost <table> </table> tags that have a
specific string in that table - in this case >Final<.

Any help would be greatly appreciated. If there are other newsgroups
dedicated to regular expressions I would be happy to redirect my post
there.

Thanks in advance,
Greg

Nov 20 '05 #3
Cor,

1) I want to learn about regular expressions. I wrote a lot of code
to extract data from HTML before I got that chapter in Balena's book,
using the VB string processing commands and now find that a few lines
of regex does the job of dozens lines of my current code.
2) A few months ago, I asked a more general question along the same
lines as the one you have responded to and it was suggested that
regex's were the way to go.
3) Please give me a suggestion as to how to use mshtl. I'm learning
VB.net partly as a hobby (although I have some things I would like to
use it for in my day job). I once was a professional programmer, and
here I'm really going to date myself, I spent 6 years at IBM writing
tons of Fortran. So....some aspects of programming I can hang in
there with anyone, but in other aspects (anything that's become
mainstream in the last 20 years say) I'm a newbie.

I am very appreciative of any help and guidance.

Greg

On Thu, 13 May 2004 15:24:44 +0200, "Cor Ligthert"
<no**********@p lanet.nl> wrote:
Hi Greg,

Why are you not using mshtml and process the text directly?

Cor


Nov 20 '05 #4
Greg,
The following sites provide a wealth of information on regular expressions.

A tutorial & reference on using regular expressions:
http://www.regular-expressions.info/

The MSDN's documentation on regular expressions:
http://msdn.microsoft.com/library/de...geElements.asp

Instead of writing your own parser or using RegEx, have you considered using
mshtml as Cor suggested or a SgmlReader (HTML reader)?

http://www.gotdotnet.com/Community/U...4-C3BD760564BC

Hope this helps
Jay

"Greg Vereschagin" <gr****@optonli ne.net> wrote in message
news:ko******** *************** *********@4ax.c om...
I'm trying to figure out a regular expression that will match the
innermost tag and the contents in between. Specifically, the string
that I am attempting to match looks as follows:

...<table>...<t able>...>Final< ...</table>...</table>...

I want to match: <table>...>Fina l<...</table> from this example.

The string could also, of course, look like the following:

....<table>...< table>...</table>...<table >...>Final<.. .</table>...<table >...<
/table>...</table>...
I am looking for the innermost <table> </table> tags that have a
specific string in that table - in this case >Final<.

Any help would be greatly appreciated. If there are other newsgroups
dedicated to regular expressions I would be happy to redirect my post
there.

Thanks in advance,
Greg

Nov 20 '05 #5
Hi Greg,

I am one of those in this newsgroup who knows someting more about the
document object model.
DOM

When you are acting with HTML or better to say DHTML you have to know have
to know more about DHTML.

Using the DOM you can do OOP programming, while with the reged it is more in
a classic procedural way. (The regex is more something you find back in
scripting languages).

I have no problem to guide you a little bit, however before you see the
tools I think it is better to have a look at that Document Object Model.

The document object model is described by W3C however looking at that site
is in my opinion a endless way to go and you never find something because of
the impossible way everything is everytimge by someone described in his own
way.

On/in Msdn it is also hard to find however better. You can search using
always the keyword "Object".

This is the document object itself
http://msdn.microsoft.com/library/de...j_document.asp

The head object
http://msdn.microsoft.com/library/de...jects/head.asp
This is the body object
http://msdn.microsoft.com/library/de...jects/body.asp

Mshtml are the classes to access those objects in a OOP way. However it are
endless classes which when referenced in your program have endless members.

You never should import it in your IDE but always do the reference direct
before what you need as example mshtml.document 2 bla bla

When you are busy with these classes in VS net you have to set at the help
the search path to all.

Have a look at those links

I hope this helps?

Cor
Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2031
by: Programatix | last post by:
Hi, I'm working on a project which includes WebServices and Windows Form application. The Windows Form application will call the WebServices to retrieve data from database. The data will be returned as DataSet. Now, here's the problem. On .NET Framework 1.1, if any rows in the dataset returned contain errors (marked by calling the SetColumnError() method or
2
1814
by: Ohaya | last post by:
Hi, We've been having a problem with one particular page that has a button on it, and a "tall" image (top-to-bottom). The button calls some simple Javascript to print the frame in which the image is located, and what is happening in the field is that the image only gets partly printed. Only the first page gets printed, and the bottom of the image, which should get printed on a 2nd page, is not printed. Also, the bottom of the first...
14
2850
by: Steve McLellan | last post by:
Hi, Sorry to repost, but this is becoming aggravating, and causing me a lot of wasted time. I've got a reasonably large mixed C++ project, and after a number of builds (but not a constant number) linking (and sometimes compiling) becomes immensely slow, and task manager shows that link.exe (or cl.exe) is barely using any processor time, but an awful lot of RAM (around 150-200MB). I'm going to keep an eye on page faults since I can't...
67
2957
by: Scott M. | last post by:
Can anyone give me any ideas on why VS.NET 2003 running on XP Pro. (P4's with 1GB RAM) would take over 3 minutes to simply create a new ASP.NET Web Application on http://localhost? It seems that the IIS directory gets created right away, but it is not configured as an application directory until several minutes go by. Thanks, Scott M.
10
2189
by: Extremest | last post by:
I know there are ways to make this a lot faster. Any newsreader does this in seconds. I don't know how they do it and I am very new to c#. If anyone knows a faster way please let me know. All I am doing is quering the db for all the headers for a certain group and then going through them to find all the parts of each post. I only want ones that are complete. Meaning all segments for that one file posted are there. using System;
3
3016
by: Beavis | last post by:
I hate to repost a message, but I am still at the same point where I was when I originally posted, and hopefully someone else will see this one... Ok, so I have gone off and documented the lifecycle of a page with a custom composite control on it. You can find that document here: http://www.ats-engineers.com/lifecycle.htm
0
9696
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10583
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10288
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9420
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7824
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5680
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5863
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4062
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3128
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.