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 3 2154
How about trying this http://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?
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>)
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>) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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': ' + @category);commandType=StoredProcedure; message=@message; category=@category
I am looking to retrive name value...
|
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 id="machines" class="noborders inred"
style="margin:2em 4em;background-color:#ddd;">
|
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 is not case-sententive.
|
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
|
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 word string? if so plz
help me out. i'm in badly need.
| |
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)" ...
|
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 expressions. Let's say my regular
expression is:
|
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 to the expression (not the matches) at runtime?
Thanks,
Mike
|
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 Unicode equivalent of HTML's " ".
This can create some strange bugs.
Is the current default...
|
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
"contain" another expression, like in:
"^strange line (\w+) and (\w+)$" and "^strange line (\w+) (?:.*?)$"...
|
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...
| |
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,...
|
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...
|
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 launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |