473,721 Members | 2,234 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Second Try - Regex Question

I need a regex to do this.
Ignore < possibleWhiteSp ace 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.
Dec 30 '06 #1
3 1129
"Just Me" <news.microsoft .comwrote in news:u1kfspELHH A.3552
@TK2MSFTNGP03.p hx.gbl:
I need a regex to do this.
Ignore < possibleWhiteSp ace 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.Gro ups for details.

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

RegEx.Replace(M yHTML, "(\s)*\>", ">")

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

I hope that's what you want.
Dec 31 '06 #2
parsing ""(\s)*>", ">")" - Too many )'s. // Error from regex.
[\w|\d]*=.*This almost works, but it leaves out all the text contained by
the element.

"Spam Catcher" <sp**********@r ogers.comwrote in message
news:Xn******** *************** ***********@127 .0.0.1...
"Just Me" <news.microsoft .comwrote in news:u1kfspELHH A.3552
@TK2MSFTNGP03.p hx.gbl:
>I need a regex to do this.
Ignore < possibleWhiteSp ace 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.Gro ups for details.

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

RegEx.Replace(M yHTML, "(\s)*\>", ">")

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

I hope that's what you want.

Dec 31 '06 #3
Done it.

[A-Za-z0-9]*=.*?>| [A-Za-z0-9]*=.*?\sp
"Just Me" <news.microsoft .comwrote in message
news:OD******** ******@TK2MSFTN GP03.phx.gbl...
parsing ""(\s)*>", ">")" - Too many )'s. // Error from regex.
[\w|\d]*=.*This almost works, but it leaves out all the text contained
by the element.

"Spam Catcher" <sp**********@r ogers.comwrote in message
news:Xn******** *************** ***********@127 .0.0.1...
>"Just Me" <news.microsoft .comwrote in news:u1kfspELHH A.3552
@TK2MSFTNGP03. phx.gbl:
>>I need a regex to do this.
Ignore < possibleWhiteSp ace 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.Gro ups 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.


Dec 31 '06 #4

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

Similar topics

4
4376
by: engwar1 | last post by:
Not sure where to ask this. Please suggest another newsgroup if this isn't the best place for this question. I'm new to both vb.net and regex. I need a regular expression that will validate what people are entering as their new password. Must be between 6 and 10 characters Must be alphanumeric only Can not be the word "password" in any case ie "pAsSworD" should also be denied.
4
9761
by: aevans1108 | last post by:
expanding this message to microsoft.public.dotnet.xml Greetings Please direct me to the right group if this is an inappropriate place to post this question. Thanks. I want to format a numeric value according to an arbitrary regular expression.
2
3423
by: Tim Conner | last post by:
Hi, Thanks to Peter, Chris and Steven who answered my previous answer about regex to split a string. Actually, it was as easy as create a regex with the pattern "/*-+()," and most of my string was splitted. I am fascinated to the powerfull use of this RegEx class, so I wonder if it could go a step further. As a question, can regex be used to valid a set of different functions ? Example : Suppose I have to verify the correctness of an...
5
5100
by: Chris | last post by:
How Do I use the following auto-generated code from The Regulator? '------------------------------------------------------------------------------ ' <autogenerated> ' This code was generated by a tool. ' Runtime Version: 1.1.4322.2032 ' ' Changes to this file may cause incorrect behavior and will be lost if ' the code is regenerated. ' </autogenerated>
6
5896
by: Martin Evans | last post by:
Sorry, yet another REGEX question. I've been struggling with trying to get a regular expression to do the following example in Python: Search and replace all instances of "sleeping" with "dead". This parrot is sleeping. Really, it is sleeping. to This parrot is dead. Really, it is dead.
4
2641
by: Chris | last post by:
Hi Everyone, I am using a regex to check for a string. When all the file contains is my test string the regex returns a match, but when I embed the test string in the middle of a text file a match is never returned. The string that I give to the regex is one that contains the entire contents of a text file. I'm using the multi-line option and I've also tried stripping out the VbCr
7
2587
by: Extremest | last post by:
I am using this regex. static Regex paranthesis = new Regex("(\\d*/\\d*)", RegexOptions.IgnoreCase); it should find everything between parenthesis that have some numbers onyl then a forward slash then some numbers. For some reason I am not getting that. It won't work at all in 2.0
6
4207
by: Phil Barber | last post by:
I am using Regex to validate a file name. I have everything I need except I would like the dot(.) in the filename only to appear once. My question is it possible to allow one instance of character but not two or more? example myfile.doc = good My.file.doc = not good if you could give an example of the expression pattern that would most helpful. thanks phil
6
2072
by: | last post by:
Hi all, Sorry for the lengthy post but as I learned I should post concise-and-complete code. So the code belows shows that the execution of ValidateAddress consumes a lot of time. In the test it is called a 100 times but in my real app it could be called 50000 or more times. So my question is if it is somehow possible to speed this up and if so how
0
8840
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
8730
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
9215
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...
1
9131
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
4484
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4753
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3189
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
2
2576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2130
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.