p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > .NET > Other .NET > General .NET
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.

Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 24th, 2006, 03:27 AM
Registered User
 
Join Date: May 2006
Location: Delhi, Delhi, India.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default match string in more than one line using Regex

Hi all,

I need to match string from {=BeginCatRecords=} to {=EndCatRecords=}....

Here is the HTML code from a file (categories.html), I a reading in a variable st :

<TABLE width="100%" border="0" align="center" cellpadding="0" cellSpacing=0 >
    <TR valign="top" >
        {=BeginCatRecords=}<TD width="45%" align='center' style='border:1px #F4EED4 solid;'><Table align='center' border="0"><tr><td align='center' style="padding-top:15px;"><a href="{=CatLink=}"><IMG SRC="images/category/{=CatImg=}" border="0" width="150"></a><BR><a href="{=CatLink=}" class='catlinks'><strong>{=CatName=}</a></strong></td></tr><tr><td><table width="90%" border='0' align="center" cellpadding="0" cellSpacing=0><tr><td align='left'>{=CatDesc=}</td></tr></table></td></tr></table></td><td width='5%'>&nbsp;</td>{=EndCatRecords=}
    </TR>
    <TR><TD colspan='2'>&nbsp;</TD></TR>
</TABLE>

In this file, from {=BeginCatRecords=} to {=EndCatRecords=} is written in one line.. and it is working fine...

But if I split it in multiline like :

{=BeginCatRecords=}
<TD width="45%" align='center' style='border:1px #F4EED4 solid;'>
<Table align='center' border="0">
    <tr><td align='center' style="padding-top:15px;"><a href="{=CatLink=}"><IMG SRC="images/category/{=CatImg=}" border="0" width="150"></a><BR><a href="{=CatLink=}" class='catlinks'><strong>{=CatName=}</a></strong></td></tr><tr><td><table width="90%" border='0' align="center" cellpadding="0" cellSpacing=0><tr><td align='left'>{=CatDesc=}</td></tr></table></td></tr></table></td><td width='5%'>&nbsp;</td>
{=EndCatRecords=}

It stops working...

Below is the code I am using to match the string :

string NavMatch = null;
pattern = @"{=BeginCatRecords=}.*?{=EndCatRecords=}";
Match MatchTop = Regex.Match(st, pattern, RegexOptions.Multiline);
NavMatch = MatchTop.ToString();


I suppose, I need to change either the pattern or I am missing any option while matching the string...

If you have any other logic to do the needful, please let me know..

Please help..

Suman Singh
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Search for a String Match combo Box tsadok VB Databases Basics 0 January 27th, 2008 02:24 AM
STRING EXACT MATCH ricespn Beginning VB 6 6 November 12th, 2007 01:18 PM
need to match string dynamically dipsut XSLT 2 May 25th, 2007 09:49 AM
Reading a string from line by line vaidyapragati ASP.NET 2.0 Professional 1 May 3rd, 2007 09:43 AM
use regex to split string store in dictionary edman747 VB How-To 0 January 29th, 2007 12:02 AM



All times are GMT -4. The time now is 11:33 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc