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

How to use regular expressions to get data

Hi !!

What regular expression should I write to get data from an html tag?

Example: <title> The data I want to retrieve </title>

I want to get "The data I want to retrieve"

Could be right this one? @<\s* (title)\s* > [(\s* \w+)]+ (</title>)+

Thanks
Nov 16 '05 #1
3 2137
How about trying this
http://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?

Nov 16 '05 #2
Paula wrote:
What regular expression should I write to get data from an html tag?

Example: <title> The data I want to retrieve </title>

I want to get "The data I want to retrieve"

Could be right this one? @<\s* (title)\s* > [(\s* \w+)]+ (</title>)+


Try this:

Regex regex = new Regex(@"((?:<\w+>\s*)(?<data>.+)(?:\s*</\w+>))",
RegexOptions.ExplicitCapture);

which will capture your data (and only your data) to a group named
"data", ignoring beginning and trailing whitespace.
--
Take care,
Ken
(to reply directly, remove the cool car. <sigh>)
Nov 16 '05 #3
Ken Arway wrote:

Try this:

Regex regex = new Regex(@"((?:<\w+>\s*)(?<data>.+)(?:\s*</\w+>))",
RegexOptions.ExplicitCapture);

which will capture your data (and only your data) to a group named
"data", ignoring beginning and trailing whitespace.


Ooops, should have used non-greedy:

Regex regex = new Regex(@"((?:<\w+>\s*)(?<data>.+?)(?:\s*</\w+>))",
RegexOptions.ExplicitCapture);

--
Take care,
Ken
(to reply directly, remove the cool car. <sigh>)
Nov 16 '05 #4

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

Similar topics

11
by: Martin Robins | last post by:
I am trying to parse a string that is similar in form to an OLEDB connection string using regular expressions; in principle it is working, but certain character combinations in the string being...
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. ...
4
by: Arjen | last post by:
Hi, I need some regular expressions but don't know how to create them. If somebody knows a good, easy to use, readable tool. Please tell me. I have a textbox. - The user must enter data. (it...
7
by: norton | last post by:
Hello, Does any one know how to extact the following text into 4 different groups(namely Date, Artist, Album and Quality)? - Artist - Album Artist - Album - Artist - Album - Artist -...
4
by: lucky | last post by:
hi there!! i'm looking for a code snipett wich help me to search some words into a particular string and replace with a perticular word. i got a huge data string in which searching traditional...
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...
9
by: Pete Davis | last post by:
I'm using regular expressions to extract some data and some links from some web pages. I download the page and then I want to get a list of certain links. For building regular expressions, I use...
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...
2
by: John Nagle | last post by:
Regular expressions are compiled in ASCII mode unless Unicode mode is specified to "rc.compile". The difference is that regular expressions in ASCII mode don't recognize things like Unicode...
10
by: Thomas Dybdahl Ahle | last post by:
Hi, I'm writing a program with a large data stream to which modules can connect using regular expressions. Now I'd like to not have to test all expressions every time I get a line, as most of...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.