473,385 Members | 1,740 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,385 software developers and data experts.

Regex beginner problem

Hi,

I have a beginner of C# and I need to fix the bug for someone!!

I have the codes like this

Regex re = new Regex(@"<TR VALIGN=top><TD></TD>.*?</TD></TR>");
MatchCollection theMatches = re.Matches(content);
ArrayList list = new ArrayList();
foreach (Match theMatch in theMatches)

for the string at the bottom...
some how it couldn't get any value ( couldn't get into the foreach
loop )

Does howone point out the problem ??
Please help me, thanks.
----------------------------------------
<TR VALIGN=top><TD></TD><TD><IMG SRC="/icons/ecblank.gif" BORDER=0
HEIGHT=1 WIDTH=16 ALT=""><FONT SIZE=1
FACE="Verdana"><li><br></FONT></TD><TD><FONT SIZE=1 COLOR="0000ff"
FACE="Verdana"><A
HREF="/webcorannc.nsf/1c5fa13a6eee416848256db2000356de/88c789fbb737109c48256dc1002fbbcf?OpenDocument">Oct
16 2003</A></FONT></TD><TD><FONT SIZE=1 COLOR="0000ff"
FACE="Verdana"><A
HREF="/webcorannc.nsf/1c5fa13a6eee416848256db2000356de/88c789fbb737109c48256dc1002fbbcf?OpenDocument">Sal es
in open market at own discretion on 15/10/2003. 8,408,000 warrants
pertaining to director/substantial shareholder CHUA HAI
KUEY</A></FONT></TD><TD><IMG SRC="/icons/ecblank.gif" BORDER=0
HEIGHT=16 WIDTH=1 ALT=""></TD></TR>

<TR VALIGN=top><TD></TD><TD><IMG SRC="/icons/ecblank.gif" BORDER=0
HEIGHT=1 WIDTH=16 ALT=""><FONT SIZE=1
FACE="Verdana"><li><br></FONT></TD><TD><FONT SIZE=1 COLOR="0000ff"
FACE="Verdana"><A
HREF="/webcorannc.nsf/1c5fa13a6eee416848256db2000356de/71ee5070be7b3a1d48256dc1002f178f?OpenDocument">Oct
16 2003</A></FONT></TD><TD><FONT SIZE=1 COLOR="0000ff"
FACE="Verdana"><A
HREF="/webcorannc.nsf/1c5fa13a6eee416848256db2000356de/71ee5070be7b3a1d48256dc1002f178f?OpenDocument">Sal es
in open market at own discretion on 15/10/2003. 8,408,000 warrants
pertaining to director/substantial shareholder CHUA HAI
KUEY</A></FONT></TD><TD><IMG SRC="/icons/ecblank.gif" BORDER=0
HEIGHT=16 WIDTH=1 ALT=""></TD></TR>

<TR VALIGN=top><TD></TD><TD><IMG SRC="/icons/ecblank.gif" BORDER=0
HEIGHT=1 WIDTH=16 ALT=""><FONT SIZE=1
FACE="Verdana"><li><br></FONT></TD><TD><FONT SIZE=1 COLOR="0000ff"
FACE="Verdana"><A
HREF="/webcorannc.nsf/1c5fa13a6eee416848256db2000356de/11404ba32a1043fc48256db3003b1e98?OpenDocument">Oct
02 2003</A></FONT></TD><TD><FONT SIZE=1 COLOR="0000ff"
FACE="Verdana"><A
HREF="/webcorannc.nsf/1c5fa13a6eee416848256db2000356de/11404ba32a1043fc48256db3003b1e98?OpenDocument">Oth ers
on 01/10/2003. 4,320,000 shares pertaining to substantial shareholder
CHUA KON SENG</A></FONT></TD><TD><IMG SRC="/icons/ecblank.gif"
BORDER=0 HEIGHT=16 WIDTH=1 ALT=""></TD></TR>

Ginola
Nov 15 '05 #1
2 1278
gi****@fake.email.com (Ginola) wrote in
news:3f*************@msnews.microsoft.com:
Hi,

I have a beginner of C# and I need to fix the bug for someone!!

I have the codes like this

Regex re = new Regex(@"<TR VALIGN=top><TD></TD>.*?</TD></TR>");
MatchCollection theMatches = re.Matches(content);
ArrayList list = new ArrayList();
foreach (Match theMatch in theMatches)

for the string at the bottom...
some how it couldn't get any value ( couldn't get into the
foreach loop )


Ginola,

You need to have your regex process the HTML as a single line of
text:

Regex re = new Regex(@"<TR VALIGN=top><TD></TD>.*?</TD></TR>",
RegexOptions.Singleline);
Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/
Nov 15 '05 #2
You need to specify the Singleline option, which will allow the "." in your
expression to match across multiple lines:

Regex re = new Regex(@"<TR
VALIGN=top><TD></TD>.*?</TD></TR>",RegexOptions.Singleline);

--
Veuillez m'excuser, mon Français est très pauvre. Cependant, si vous voyez
mauvais C #, c'est mon défaut!
"Ginola" <gi****@fake.email.com> wrote in message
news:3f*************@msnews.microsoft.com...
Hi,

I have a beginner of C# and I need to fix the bug for someone!!

I have the codes like this

Regex re = new Regex(@"<TR VALIGN=top><TD></TD>.*?</TD></TR>");
MatchCollection theMatches = re.Matches(content);
ArrayList list = new ArrayList();
foreach (Match theMatch in theMatches)

for the string at the bottom...
some how it couldn't get any value ( couldn't get into the foreach
loop )

Does howone point out the problem ??
Please help me, thanks.
----------------------------------------
<TR VALIGN=top><TD></TD><TD><IMG SRC="/icons/ecblank.gif" BORDER=0
HEIGHT=1 WIDTH=16 ALT=""><FONT SIZE=1
FACE="Verdana"><li><br></FONT></TD><TD><FONT SIZE=1 COLOR="0000ff"
FACE="Verdana"><A
HREF="/webcorannc.nsf/1c5fa13a6eee416848256db2000356de/88c789fbb737109c48256
dc1002fbbcf?OpenDocument">Oct 16 2003</A></FONT></TD><TD><FONT SIZE=1 COLOR="0000ff"
FACE="Verdana"><A
HREF="/webcorannc.nsf/1c5fa13a6eee416848256db2000356de/88c789fbb737109c48256
dc1002fbbcf?OpenDocument">Sales in open market at own discretion on 15/10/2003. 8,408,000 warrants
pertaining to director/substantial shareholder CHUA HAI
KUEY</A></FONT></TD><TD><IMG SRC="/icons/ecblank.gif" BORDER=0
HEIGHT=16 WIDTH=1 ALT=""></TD></TR>

<TR VALIGN=top><TD></TD><TD><IMG SRC="/icons/ecblank.gif" BORDER=0
HEIGHT=1 WIDTH=16 ALT=""><FONT SIZE=1
FACE="Verdana"><li><br></FONT></TD><TD><FONT SIZE=1 COLOR="0000ff"
FACE="Verdana"><A
HREF="/webcorannc.nsf/1c5fa13a6eee416848256db2000356de/71ee5070be7b3a1d48256
dc1002f178f?OpenDocument">Oct 16 2003</A></FONT></TD><TD><FONT SIZE=1 COLOR="0000ff"
FACE="Verdana"><A
HREF="/webcorannc.nsf/1c5fa13a6eee416848256db2000356de/71ee5070be7b3a1d48256
dc1002f178f?OpenDocument">Sales in open market at own discretion on 15/10/2003. 8,408,000 warrants
pertaining to director/substantial shareholder CHUA HAI
KUEY</A></FONT></TD><TD><IMG SRC="/icons/ecblank.gif" BORDER=0
HEIGHT=16 WIDTH=1 ALT=""></TD></TR>

<TR VALIGN=top><TD></TD><TD><IMG SRC="/icons/ecblank.gif" BORDER=0
HEIGHT=1 WIDTH=16 ALT=""><FONT SIZE=1
FACE="Verdana"><li><br></FONT></TD><TD><FONT SIZE=1 COLOR="0000ff"
FACE="Verdana"><A
HREF="/webcorannc.nsf/1c5fa13a6eee416848256db2000356de/11404ba32a1043fc48256
db3003b1e98?OpenDocument">Oct 02 2003</A></FONT></TD><TD><FONT SIZE=1 COLOR="0000ff"
FACE="Verdana"><A
HREF="/webcorannc.nsf/1c5fa13a6eee416848256db2000356de/11404ba32a1043fc48256
db3003b1e98?OpenDocument">Others on 01/10/2003. 4,320,000 shares pertaining to substantial shareholder
CHUA KON SENG</A></FONT></TD><TD><IMG SRC="/icons/ecblank.gif"
BORDER=0 HEIGHT=16 WIDTH=1 ALT=""></TD></TR>

Ginola

Nov 15 '05 #3

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

Similar topics

4
by: aevans1108 | last post by:
expanding this message to microsoft.public.dotnet.xml Greetings Please direct me to the right group if this is an inappropriate place to post this question. Thanks. I want to format a...
4
by: aevans1108 | last post by:
expanding this message to microsoft.public.dotnet.xml Greetings Please direct me to the right group if this is an inappropriate place to post this question. Thanks. I want to format a...
0
by: =?Utf-8?B?Slc=?= | last post by:
I read some advice given to someone here to use RegEx to get around invalid XML characters. Goran Djuranovic asked the question in 1-21-2007. The advice was given by Keith Patrick and Goran...
10
by: bullockbefriending bard | last post by:
first, regex part: I am new to regexes and have come up with the following expression: ((1|),(1|)/){5}(1|),(1|) to exactly match strings which look like this: 1,2/3,4/5,6/7,8/9,10/11,12 ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.