Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
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 Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 24th, 2006, 02:27 AM
Registered User
 
Join Date: May 2006
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





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 08:49 AM
Reading a string from line by line vaidyapragati ASP.NET 2.0 Professional 1 May 3rd, 2007 08:43 AM
use regex to split string store in dictionary edman747 VB How-To 0 January 29th, 2007 12:02 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.