[regex-coach] Regular Expression Help

Hi guys. Hopefully someone can help me. I have the following chunk of XML code. I need to extract the last section, from <w:p> to </w:p> (inclusive) in the section that contains the [INTRODUCTION] text. Here is my current attempt: <w:p>.*(?=<w:t>).*(?=INTRODUCTION).*(?=</w:t>).*?</w:p> Problem is, that regular expression grabs the entire chunk, not just the last section. Can someone please advise. <w:p> <w:pPr> <w:rPr> <w:rFonts w:ascii="Tahoma" w:h-ansi="Tahoma" w:cs="Tahoma"/> <wx:font wx:val="Tahoma"/> <w:sz w:val="20"/> <w:sz-cs w:val="20"/> </w:rPr> </w:pPr> </w:p> <w:p> <w:pPr> <w:rPr> <w:rFonts w:ascii="Tahoma" w:h-ansi="Tahoma" w:cs="Tahoma"/> <wx:font wx:val="Tahoma"/> <w:b/> <w:color w:val="000080"/> <w:sz w:val="40"/> <w:sz-cs w:val="40"/> </w:rPr> </w:pPr> </w:p> <w:p> <w:pPr> <w:rPr> <w:rFonts w:ascii="Tahoma" w:h-ansi="Tahoma" w:cs="Tahoma"/> <wx:font wx:val="Tahoma"/> <w:b/> <w:color w:val="000080"/> <w:sz w:val="40"/> <w:sz-cs w:val="40"/> </w:rPr> <w:t>Introduction</w:t> </w:pPr> </w:p> <w:p> <w:pPr> <w:rPr> <w:rFonts w:ascii="Tahoma" w:h-ansi="Tahoma" w:cs="Tahoma"/> <wx:font wx:val="Tahoma"/> <w:sz w:val="20"/> <w:sz-cs w:val="20"/> </w:rPr> </w:pPr> <w:r> <w:rPr> <w:rFonts w:ascii="Tahoma" w:h-ansi="Tahoma" w:cs="Tahoma"/> <wx:font wx:val="Tahoma"/> <w:sz w:val="20"/> <w:sz-cs w:val="20"/> </w:rPr> <w:t>[INTRODUCTION]</w:t> </w:r> </w:p>

Any idea if I am doing somehting wrong? The expression works great in Regex Coach, but once in ASP.NET 2.0, it freezes on the myRegex.Match command... Dim oM As Match Dim myRegex As Regex myRegex = New Regex("(?m-si)(?><w:p.+(\r?\n(?!<w:p>).*)*INTRODUCTION)(?s).+?</w:p>") oM = myRegex.Match(strReport) strReport = Replace(strReport, oM.Value, "Blah") On 12/31/06, Thomas Wölk <lists@wir-vermessen.de> wrote:
* Jordan Marton <jordan.marton@gmail.com> writes:
Here is my current attempt: <w:p>.*(?=<w:t>).*(?=INTRODUCTION).*(?=</w:t>).*?</w:p>
Just a fleeting thought...
(?ims).*\n(<w:p>.*?(?=\[INTRODUCTION\]).*?</w:p>)
-- Thomas.
_______________________________________________ regex-coach site list regex-coach@common-lisp.net http://common-lisp.net/mailman/listinfo/regex-coach
participants (2)
-
Jordan Marton
-
Thomas Wölk