Re: Second Try - Regex Question

Tech-Archive recommends: Fix windows errors by optimizing your registry



"Just Me" <news.microsoft.com> wrote in news:u1kfspELHHA.3552
@TK2MSFTNGP03.phx.gbl:

I need a regex to do this.


Ignore < possibleWhiteSpace htmlTag

Replace whitespace anything >

With >

Basically I need to remove anything following the html tag up to and
including the closing tag

Any help is appreciated.

Hmmm are you trying to do this?

< TAG > becomes < TAG>?

You can try this to match the entire tag (and the parts within the tag):

\<(?<leading>\s)*(?<tag>\w)+(?<trailing>\s)*\>

The regex above uses named groups so that you can references parts of
the matches in code. Take a look at RegEx.Match.Groups for details.

If you want to do pure search, replace, this should work:

RegEx.Replace(MyHTML, "(\s)*\>", ">")

(\s)+ matches zero or more spaces. \> matches the trailing tag.

I hope that's what you want.
.



Relevant Pages

  • Re: xml.parsers.expat loading xml into a dict and whitespace
    ... whitespace after a tag to that part of the dict. ... Let's say I write a simple xml parser, for an xml file that just loads ...
    (comp.lang.python)
  • Re: Future of LISP. Alternative to XML. Web 3.0?
    ... can use the URL directly because not XML limitations for tag names. ... I also don't understand why would anybody need multiple namespaces per ... So you would discard all text nodes containing just whitespace, ... Would you collapse *any* whitespace ...
    (comp.lang.lisp)
  • Re: Extra Space in IE - The Sequel
    ... characters (which includes space chars, newlines, carriage returns, ... ASCII char 255 etc etc) are to be collapsed to a single whitespace ... end tag. ... Authors should rely on user agents not to render whitespace after a start ...
    (comp.infosystems.www.authoring.html)
  • Re: asp.net 1.1 generates spurious whitespace
    ... there are 2 tab characters between the end of the img tag and the ... Visual Studio .NET 2002 or 2003). ... notorious for mangling your HTML into what *they* want it to look ... can't handle the extraneous whitespace, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: 2 Questions about validations
    ... [XML requires whitespace between attributes] ... > My curious mind wonders why any one would find it necessary to set up ... the end tag. ...
    (comp.infosystems.www.authoring.html)