473,378 Members | 1,382 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,378 software developers and data experts.

Regular expression to find any HTML tag with/without attributes

Hi,

I've written the code to read an HTML file into a string. Now I want to
replace tags with other things. The problem comes up that some row tags
(<tr>) are just a plain tag like <tr>, and sometimes they have attributes,
like <tr bgcolor=''>. My code right now looks like:

text = Regex.Replace(text, "<tr*>", "")

What would make this work?
Nov 21 '05 #1
2 13353
Hi,

http://www.regexlib.com/REDetails.aspx?regexp_id=464

Ken
--------------
"Eric" <Er**@discussions.microsoft.com> wrote in message
news:36**********************************@microsof t.com...
Hi,

I've written the code to read an HTML file into a string. Now I want to
replace tags with other things. The problem comes up that some row tags
(<tr>) are just a plain tag like <tr>, and sometimes they have attributes,
like <tr bgcolor=''>. My code right now looks like:

text = Regex.Replace(text, "<tr*>", "")

What would make this work?

Nov 21 '05 #2
Ken,

Thanks for this link.

Cor

"Ken Tucker [MVP]"
Hi,

http://www.regexlib.com/REDetails.aspx?regexp_id=464

Ken
--------------
"Eric" <Er**@discussions.microsoft.com> wrote in message
news:36**********************************@microsof t.com...
Hi,

I've written the code to read an HTML file into a string. Now I want to
replace tags with other things. The problem comes up that some row tags
(<tr>) are just a plain tag like <tr>, and sometimes they have attributes,
like <tr bgcolor=''>. My code right now looks like:

text = Regex.Replace(text, "<tr*>", "")

What would make this work?

Nov 21 '05 #3

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

Similar topics

7
by: YoBro | last post by:
Hi I have used some of this code from the PHP manual, but I am bloody hopeless with regular expressions. Was hoping somebody could offer a hand. The output of this will put the name of a form...
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...
23
by: Charles Law | last post by:
Does anyone have a regex pattern to parse HTML from a stream? I have a well structured file, where each line is of the form <sometag someattribute='attr'>text</sometag> for example <SPAN...
7
by: Patient Guy | last post by:
Coding patterns for regular expressions is completely unintuitive, as far as I can see. I have been trying to write script that produces an array of attribute components within an HTML element. ...
3
by: Ori | last post by:
Hi , I'm working with C#.NET and I'm looking for the following. I have a web page content and I want to pull all the text which appear in the page without all the HTML tags. I know that there...
10
by: hclugano | last post by:
Hi! There is a SQL Create Table statement, for example: CREATE TABLE . ( IDENTITY (1, 1) NOT NULL, NOT NULL, ( 15) NOT NULL ..... ) ON
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: crackRockSteady | last post by:
Hi, As a project for a friend I need to capture every album name from his website (long story). Instead of going through page by page I thought it would be a good idea to scrape the html using...
14
by: Andy B | last post by:
I need to create a regular expression that will match a 5 digit number, a space and then anything up to but not including the next closing html tag. Here is an example: <startTag>55555 any...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.