473,461 Members | 1,681 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Regex problem with with carriage returns

I have placed html in the database. I am trying to capture items between two
text blocks.
The content string is like the following
</FONT><BR>
<BR>
<BR>
some text here<BR>
<A NAME="

I am trying to capture the 'some text here' with the following regex. I am
using the following reg expression however i believe i am having problems
with the carriage returns.

Dim ResultString As String
Try
ResultString = Regex.Match(SubjectString,
"<BR>(\r\n)<BR>(\r\n)<BR>(.*?)<BR>(\r\n)<A",
RegexOptions.Singleline).Groups(1).Value
Catch ex As ArgumentException
'Syntax error in the regular expression
End Try

When i run this in vb.net app resultstring is always ""

Any one have an idea of what i am doing wrong here?
thx
dave

Jul 21 '05 #1
1 1483
Dave,

I'm not an expert on regular expressions, but I have had to deal with some
recently and have learned enough that I might be able to help.

In your original regular expression you forgot about the carriage return
just prior to your "some text here".

Change: "<BR>(\r\n)<BR>(\r\n)<BR>(.*?)<BR>(\r\n)<A"
To "<BR>(\r\n)<BR>(\r\n)<BR>(\r\n)(.*)<BR>(\r\n)< A"

Note that I also removed the "?". I don't believe it is needed. Also, your
desired text would be the fourth group, not the first, so change
Groups(1).Value to Groups(4).Value.

For an even simpler expression, try changing your regular expression to:

"<BR>\r\n(.+)<BR>" and leave Groups(1).Value as it is.

I hope this helps.

Ron

"dave" <da**@discussions.microsoft.com> wrote in message
news:7A**********************************@microsof t.com...
I have placed html in the database. I am trying to capture items between
two
text blocks.
The content string is like the following
</FONT><BR>
<BR>
<BR>
some text here<BR>
<A NAME="

I am trying to capture the 'some text here' with the following regex. I
am
using the following reg expression however i believe i am having problems
with the carriage returns.

Dim ResultString As String
Try
ResultString = Regex.Match(SubjectString,
"<BR>(\r\n)<BR>(\r\n)<BR>(.*?)<BR>(\r\n)<A",
RegexOptions.Singleline).Groups(1).Value
Catch ex As ArgumentException
'Syntax error in the regular expression
End Try

When i run this in vb.net app resultstring is always ""

Any one have an idea of what i am doing wrong here?
thx
dave

Jul 21 '05 #2

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

Similar topics

12
by: Nimmy | last post by:
Hi, I have a data file and I want to remove Carriage returns. Any one has any C code/program which does this? I am working on Windows XP machine.....I don't have access to UNIX machine. But I...
3
by: Jon | last post by:
Hi... I'm getting stumped over the something that MUST be simple...basically, I'm trying to replace the characters 0D0A with a crlf, using Regex.Replace(). The problem is, the replaced string...
1
by: George Durzi | last post by:
Consider this excerpt from some HTML. (This is a copy from View->Source, except for the comment) <TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0 border=0> <?xml version="1.0" encoding="UTF-16"?>...
6
by: Dan Hargrove | last post by:
I'm using the regex class to try and search a string for line feeds, carriage returns, and tabs. In a windows test app, I can enter the expression of \\ and this works fine. But in the ASP.net app,...
1
by: Thief_ | last post by:
I'd like to check if a textbox contains text & symbols. Sometimes it will have just carriage returns and/or spaces, and lots of them, and I want to check if this is the case so that I can clear the...
1
by: dave | last post by:
I have placed html in the database. I am trying to capture items between two text blocks. The content string is like the following </FONT><BR> <BR> <BR> some text here<BR> <A NAME=" I am...
0
by: markus.shure | last post by:
Hi, I'm noticed a problem testing a JAX-WS client with a WSE server. The JAX-WS client adds carriage returns to a SOAP header element that is signed. This causes the WSE server to raise an...
3
by: =?Utf-8?B?c2JwYXJzb25z?= | last post by:
I have a scenario where a string is sent in chunks to my app. I need to be able to identify certain tags in this partial string as it arrives. eg <DALFile>xxxxxxxxx</DALFile> I need to be able...
8
by: DotNetNewbie | last post by:
Hi, I have text in a file that looks like this: What kind of regex could get the '2' ?
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
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,...
0
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...
0
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...
0
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,...
0
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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...

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.