473,670 Members | 2,448 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Regex Select HtmlTags


Hello,

I'm looking for a way to strip all html tags from a string.
I've found several good regular expressions that do that job.

I'm using <(.|\n)*?>,

But now i would like to keep the tag if betwene the < and the > appears some
text.
What is the goal, strip all html-tags and all anchors except if the anchor
goes to a specific site, then i still need the anchor in the stripped
string.

Anybody got a suggestion ??
Kind Regards
Harry

May 3 '06 #1
1 1622
Hi Harry,

Do you need to strip out all the tags but keep certain anchor that links to
specific site in a string? If so, I think this will not be a good practice
to achieve it by Regex. Because you might have several long site names and
these might make the Regex hard to read and modify. It will be good to
write some code using String.Replace to achieve this, IMO. HTH.

Kevin Yu
Microsoft Online Community Support

=============== =============== =============== =============== =============== =
=============== ===========
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =============== =============== =
=============== ===========

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

May 4 '06 #2

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

Similar topics

0
1118
by: Justin F | last post by:
I need to parse a string, which contains SQL commands, for the batch terminator ("GO"). I came up with "\s\s" which seems to work as long as there isn't a "GO" in any comments. I have no idea how to tell RegEx to ignore "GO" if it's either in a line comment (--) or within a block comment (/* */). Any RegEx gurus know how to do this? For example, the following "GO"s should be ignored select * from Customers -- go select * from...
2
1470
by: Horizon | last post by:
Hi, I would like to build a regex that returns me the table list of a SQL SELECT request like : -SELECT * FROM tab1, tab2, tab3 -SELECT * FROM tab1, tab2 WHERE col="abc" -SELECT * FROM tab1, tab2 LIMIT 1 I tried something like that : ---
3
1171
by: Richard | last post by:
Trying to wrap my brain around Regex for the first time... I need to be able to replace Sql @NamedParameters with "?" for compliance with an extremely lame 3rd party Odbc driver. I know that this should be fairly straighforward in Regex but I'm not a Regex guru. Does anybody know how to turn this {not real Sql but demonstrates my issue}: SELECT * FROM Customers WHERE State=@State AND LastName LIKE @LastName into this
3
8252
by: Craig Buchanan | last post by:
Is there a way to combine these two Replace into a single line? Regex.Replace(Subject, "\&", "&amp;") Regex.Replace(Subject, "\'", "&apos;") Perhaps Regex.Replace(Subject, "{\&|\'}", "{&amp;|&apos;}") Thanks, Craig
8
1820
by: vbmark | last post by:
I'm new to RegEx in vb.net so I'm not sure how to do this. I want to know if a string contains two minus signs "-". If there are two then I want it to return TRUE. I also need to know if the string contains two plus signs "+". Should this be a seperate RegEx or can one RegEx check for both signs? Thanks!
7
2839
by: melanieab | last post by:
Hi, I'm trying to use DataView to find the row number in the datatable that contains "Rich" in it so that I can highlight it. It works fine when I enter the entire string (i.e. Richard), but I can't seem to make a search for "Rich" recognize that Richard is also what I want. The problem seems to be here: DataView dv = tCat.DefaultView; Regex reg = new Regex(@"^Rich");
12
8528
by: Julien ARNOUX | last post by:
Hi, I'd like to use regular expressions in sqlite query, I using apsw module but it doesn't work...Can you help me ? My script: import apsw import re path = 'db/db.db3'
3
1984
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;
11
4932
by: coflo | last post by:
Hello I would like to replace an a href link that is provided in the RSS below with my own link. The link that I am looking to replace is defined in the <description> tag within the RSS. Im guessing I need to use some sort of function in combination with regex. I am able to create a regex to find and replace the a href link very easily; however, using regex in combination with a find and replace in XSL i am extremly novice. I am wanting...
0
8466
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
8901
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...
1
8591
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
8659
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...
1
6212
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5683
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
4388
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2799
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
2037
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.