How to use regular expressions to get data | Bytes (2024)

Home Posts Topics Members FAQ

Paula

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

Subscribe Reply

3 How to use regular expressions to get data | Bytes (1) 2141 How to use regular expressions to get data | Bytes (2)

Stephen Cairns

How about trying this
http://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?

Nov 16 '05 #2

Ken Arway

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.Ex plicitCapture);

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

Ken Arway wrote:

Try this:

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

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.Ex plicitCapture);

--
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 3888

Regular expressions: parsing an "OLEDB like" connection string ...

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 parsed can completely wreck it. The string I am trying to parse is as follows: commandText=insert into (Text) values (@message + N': ' +...

.NET Framework

7 2182

Regular Expressions Challenge

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. Consider the example of the HTML element TABLE with the following attributes producing sufficient complexity within the element: <table...

Javascript

4 339

Regular expressions

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 may not be empty) - The data lenght must be between 1 to 255. - The user may add data on multiple lines. (some lines may be left empty) - The data...

ASP.NET

7 371

Regular Expressions

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 - Album- i have try this syntax but it failed

Visual Basic .NET

4 4824

Search, Replace with Regular Expression

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 way mean to secrife lots of time in asp.net. can any one give me such a expression in which i pass a data string and search word string and replace...

Visual Basic .NET

4 5150

Using regular expressions in LIKE

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 adate LIKE "2004.01.10 __:15") .... into something like this: .... where adate LIKE "2004.01.10 __:(30/15)" ...

PostgreSQL Database

9 3348

Regular Expression Matches

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 an app call The Regulator, which makes it pretty easy to build and test regular expressions. As a warning, I'm real weak with regular...

C# / C Sharp

25 5140

Get regular expression

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 (CONDUCTION DEFECT) 37.33/2 HEART (CONDUCTION DEFECT) WITH CATHETER 37.34/2 " the expression is "HEART (CONDUCTION DEFECT)". How do I gain access...

C# / C Sharp

2 2123

UNICODE mode for regular expressions - time to change the default?

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 whitespace, even when applied to Unicode strings. For example, Unicode character 0x00A0 is a "NO-BREAK SPACE", which is a form of whitespace. It's the...

Python

10 1848

Compare regular expressions

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 the time, one of them having a match means none of the others can have so. But ofcource there are also cases where a regular expression can...

Python

7701

Changing the language in Windows 10

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...

Windows Server

8029

Problem With Comparison Operator <=> in G++

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. ...

C / C++

8204

Maximizing Business Potential: The Nexus of Website Design and Digital Marketing

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...

Online Marketing

8068

Discussion: How does Zigbee compare with other wireless protocols in smart home applications?

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...

General

6424

AI Job Threat for Devs

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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...

Career Advice

1 5600

Access Europe - Using VBA to create a class based on a table - Wed 1 May

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...

Microsoft Access / VBA

3735

Windows Forms - .Net 8.0

by: adsilva |last post by:

A Windows Forms form does not have the event Unload, like VB6. What one acts like?

Visual Basic .NET

1 2222

transfer the data from one system to another through ip address

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

C# / C Sharp

1044

Comprehensive Guide to Website Development in Toronto: Expert Insights from BSMN Consultancy

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...

General

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisem*nts and analytics tracking please visit the page.

How to use regular expressions to get data | Bytes (2024)

References

Top Articles
Latest Posts
Article information

Author: Merrill Bechtelar CPA

Last Updated:

Views: 6150

Rating: 5 / 5 (70 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Merrill Bechtelar CPA

Birthday: 1996-05-19

Address: Apt. 114 873 White Lodge, Libbyfurt, CA 93006

Phone: +5983010455207

Job: Legacy Representative

Hobby: Blacksmithing, Urban exploration, Sudoku, Slacklining, Creative writing, Community, Letterboxing

Introduction: My name is Merrill Bechtelar CPA, I am a clean, agreeable, glorious, magnificent, witty, enchanting, comfortable person who loves writing and wants to share my knowledge and understanding with you.