473,513 Members | 2,412 Online
Bytes | Software Development & Data Engineering Community
+ 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 1486
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
5591
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 need to send this data file to the Unix machine once I remove the carriage retunrns from my XP machine. Thanks
3
10658
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 includes the literal \r and \n, not a CRLF. I've also tried Enviroment.Newline, but this gives the same effect. Can anyone help me with this?
1
1588
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"?> <!-- need to extract whatever is here --> </TABLE> I need to extract all the HTML that would be in the <!-- need to extract whatever is here -->...
6
1771
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, the same expression does not work, even though the same process and test strings are being used. Here's the set of code to test this process on the...
1
1171
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 multi-line textbox. What's the RegEx expression for this? VB.NET2003 -- | +-- Thief_
1
266
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 trying to capture the 'some text here' with the following regex. I am
0
1393
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 error: "The signature or decryption failed". If the carriage returns are removed, the same web service call is successful. I tried replicating the...
3
2405
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 to have a regex that will capture the start, middle and end of this file based on the tags. The problem is that the end tag may not always be...
8
1541
by: DotNetNewbie | last post by:
Hi, I have text in a file that looks like this: What kind of regex could get the '2' ?
0
7177
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...
0
7559
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...
0
7542
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...
0
5701
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...
1
5100
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...
0
3248
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...
0
1611
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
811
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
470
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...

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.