473,320 Members | 2,048 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,320 software developers and data experts.

Regular Expressions

Given an xml string s that looks like:

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE foo PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN
http://www.goo.com/xml_dtds/zoo.dtd">
<xxx version="1.01">
<zzz>ggg</zzz>
</xxx>

How do you remove the stuff within a <!DOCTYPE ... > tag such that the
result
is:

<?xml version="1.0" encoding="iso-8859-1"?>
<xxx version="1.01">
<zzz>ggg</zzz>
</xxx>

s = System.Text.RegularExpressionsSystemRegex.Replace( s, PATTERN, "")?

In other words, what should I put in for PATTERN?

I tried "<!DOCTYPE*>" but that did not work.

Thanks,
Jon
Nov 17 '05 #1
2 5839
hi Jon,

I am not sure abt the regular expression. But You can
acheive the same result using teh XmlDocument. First load
the cml to XmlDocument and then remove your second node.

regards
Sreejumon[MVP]
DOTNET makes IT happen
-----Original Message-----
Given an xml string s that looks like:

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE foo PUBLIC "-//Netscape Communications//DTD RSS 0.91//ENhttp://www.goo.com/xml_dtds/zoo.dtd">
<xxx version="1.01">
<zzz>ggg</zzz>
</xxx>

How do you remove the stuff within a <!DOCTYPE ... > tag such that theresult
is:

<?xml version="1.0" encoding="iso-8859-1"?>
<xxx version="1.01">
<zzz>ggg</zzz>
</xxx>

s = System.Text.RegularExpressionsSystemRegex.Replace( s, PATTERN, "")?
In other words, what should I put in for PATTERN?

I tried "<!DOCTYPE*>" but that did not work.

Thanks,
Jon
.

Nov 17 '05 #2
Hi Jonathan

A regex pattern that works (i.e. matches) is "<!DOCTYPE[^>]*>". i.e.

s = System.Text.RegularExpressions.Regex.Replace(s, "<!DOCTYPE[^>]*>", "")

If you want to find out more about Regular Expressions, check under
VS.NET->.NET Framework->Reference->Regular Expression Language Elements in
the VS.NET Help.

Peter

"Jonathan Wolfson" <jo*****@hotmail.com> wrote in message
news:a6**************************@posting.google.c om...
Given an xml string s that looks like:

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE foo PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN
http://www.goo.com/xml_dtds/zoo.dtd">
<xxx version="1.01">
<zzz>ggg</zzz>
</xxx>

How do you remove the stuff within a <!DOCTYPE ... > tag such that the
result
is:

<?xml version="1.0" encoding="iso-8859-1"?>
<xxx version="1.01">
<zzz>ggg</zzz>
</xxx>

s = System.Text.RegularExpressionsSystemRegex.Replace( s, PATTERN, "")?

In other words, what should I put in for PATTERN?

I tried "<!DOCTYPE*>" but that did not work.

Thanks,
Jon

Nov 17 '05 #3

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

Similar topics

8
by: Michael McGarry | last post by:
Hi, I am horrible with Regular Expressions, can anyone recommend a book on it? Also I am trying to parse the following string to extract the number after load average. ".... load average:...
1
by: Kenneth McDonald | last post by:
I'm working on the 0.8 release of my 'rex' module, and would appreciate feedback, suggestions, and criticism as I work towards finalizing the API and feature sets. rex is a module intended to make...
2
by: Sehboo | last post by:
Hi, I have several regular expressions that I need to run against documents. Is it possible to combine several expressions in one expression in Regex object. So that it is faster, or will I...
4
by: Együd Csaba | last post by:
Hi All, I'd like to "compress" the following two filter expressions into one - assuming that it makes sense regarding query execution performance. .... where (adate LIKE "2004.01.10 __:30" or...
7
by: Billa | last post by:
Hi, I am replaceing a big string using different regular expressions (see some example at the end of the message). The problem is whenever I apply a "replace" it makes a new copy of string and I...
3
by: a | last post by:
I'm a newbie needing to use some Regular Expressions in PHP. Can I safely use the results of my tests using 'The Regex Coach' (http://www.weitz.de/regex-coach/index.html) Are the Regular...
25
by: Mike | last post by:
I have a regular expression (^(.+)(?=\s*).*\1 ) that results in matches. I would like to get what the actual regular expression is. In other words, when I apply ^(.+)(?=\s*).*\1 to " HEART...
1
by: Allan Ebdrup | last post by:
I have a dynamic list of regular expressions, the expressions don't change very often but they can change. And I have a single string that I want to match the regular expressions against and find...
13
by: Wiseman | last post by:
I'm kind of disappointed with the re regular expressions module. In particular, the lack of support for recursion ( (?R) or (?n) ) is a major drawback to me. There are so many great things that can...
12
by: FAQEditor | last post by:
Anybody have any URL's to tutorials and/or references for Regular Expressions? The four I have so far are: http://docs.sun.com/source/816-6408-10/regexp.htm...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.