473,847 Members | 1,792 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can I ignore linebreaks in Regex Singleline mode?

I want to match some HTML string using Regex but the linebreaks are getting me.

Is there a way to just completely ignore linebreaks in my regular expression?

If not, how would I specify a linebreak in the regex? I know how to do begin
line/end line but that only works in non-singleline mode right?

i.e.

if I have:

<div%gt;Some text
Some more text on next line
</div>

how would I match those 3 lines together ?
Dec 31 '06 #1
1 9172
Hi,

Here's a document that explains the Singleline and Multiline options:

..NET Framework Developer's Guide
Regular Expression Options
http://msdn2.microsoft.com/en-us/library/yd1hzczs.aspx

Singleline changes the meaning of the "." character and Multiline changes
the meaning of the "^" and "$" characters.

--
Dave Sexton
http://davesexton.com/blog

"MrNobody" <Mr******@discu ssions.microsof t.comwrote in message
news:FA******** *************** ***********@mic rosoft.com...
>I want to match some HTML string using Regex but the linebreaks are getting
me.

Is there a way to just completely ignore linebreaks in my regular
expression?

If not, how would I specify a linebreak in the regex? I know how to do
begin
line/end line but that only works in non-singleline mode right?

i.e.

if I have:

<div%gt;Some text
Some more text on next line
</div>

how would I match those 3 lines together ?

Jan 1 '07 #2

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

Similar topics

1
9022
by: David Elliott | last post by:
I have an expression that works for single line but not multiline. What am I missing? expression = "<div(?<data1>.*?)>(?<data2>.*?)</div>"; MatchCollection mc = Regex.Matches(data, expression, RegexOptions.Multiline | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace); Expression works if data looks like this:
2
1304
by: Ginola | last post by:
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)
2
2709
by: Matt T. | last post by:
I am trying to replace the nested table tag in the follow string using a regular expression, but I am not having any success. I am new at using regular expressions, so I am sure I am just overlooking something simple. I thought <table.*>.*<table.*>.*</table> or some variation of that would work to create a match, but it does not. Anyone have an idea as to what would work?
6
396
by: Du Dang | last post by:
Text: ===================== <script1> ***stuff A </script1> ***more stuff <script2> ***stuff B
2
6065
by: Craig Buchanan | last post by:
I have a HTML fragment that looks like this: <tr> <td valign="top" nowrap><span class="textBold">Property ID: </span></td> <td valign="top" nowrap colspan="4" bgcolor="#F0F0F0"><b>&nbsp;01-068-24-64-1024</b></td> </tr> I am trying to extract the '' part of it.
2
244
by: japi | last post by:
Hi, as a regex starter I am having a little trouble here. suppose i want to parse the folling html fragment: <li> a </li> <li>
7
2439
by: MrNobody | last post by:
I'm trying to do some regex in C# but for some reason linebreaks are causing my regex to not work. the test string goes like this: string ss = "<tagname something=45678&somethingelse=12345>blah</tagname>\r\n<tag2>stuff</tag2>"; and my regex code is like:
6
5397
by: =?Utf-8?B?YXByMDUyNA==?= | last post by:
I am wondering if there is a devenv switch that will ignore build dependencies that are set in .xxproj files. At the command line I am attempting to build individual projects that I do not want subjected to the build dependencies set in the project files.
3
1988
by: R. K. Wijayaratne | last post by:
Hello everyone, I have something similar to the below and I am trying to select just the Block 1 markup/text <li><ul>...</ul></liwith the following RegEx @"<li>(.|\n)*<ul>(.|\n)*</ul>\n*</li>", however it selects all 3 blocks. Any ideas how to get around this? string section = Regex.Match(text, @"(<li>(.|\n)*<ul>(.|\n)*</ul>\n*</ li>)").Value;
0
9886
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
9730
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10983
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10647
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10338
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7056
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5911
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4528
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
3
3164
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.