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

Regular Expression Help!

Hi - I'll admit it.. I'm clueless using regular expressions. That's why I
was hoping someone could help me out a bit. I need to search an html file
and find strings that are between tags. For example, everything in bewtween
the <body></body> tag. As you well know, this string could span many lines,
white spaces, tabs, et.... So I need an expression that will match the
<body> tag, ingnore EVERYTHING then match the end </body> tag.

Anyone to the rescue?? :)

Thanks a lot in advance
Steve
Jul 21 '05 #1
3 3102
Hi,

I have been using this for doing the job in C#:

private string getBodyText(string inputString)
{
string pattern = "<body(<?body>.*)</body>";
Regex r = new Regex(pattern,
RegexOptions.IgnoreCase|RegexOptions.Compiled);
Match m = r.Match(inputString);
if (m.Success)
{
return m.Groups["body"].Value;
}
else
{
return inputString;
}
}

Regards,
Svend

"Steve Peterson" <fa******@fakemail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi - I'll admit it.. I'm clueless using regular expressions. That's why I
was hoping someone could help me out a bit. I need to search an html file
and find strings that are between tags. For example, everything in bewtween the <body></body> tag. As you well know, this string could span many lines, white spaces, tabs, et.... So I need an expression that will match the
<body> tag, ingnore EVERYTHING then match the end </body> tag.

Anyone to the rescue?? :)

Thanks a lot in advance
Steve

Jul 21 '05 #2
Did the trick! Thanks!!!
Steve
"Svend Dyhr Hansen" <sv***@nospam.dk> wrote in message
news:Oy**************@TK2MSFTNGP09.phx.gbl...
Hi,

I have been using this for doing the job in C#:

private string getBodyText(string inputString)
{
string pattern = "<body(<?body>.*)</body>";
Regex r = new Regex(pattern,
RegexOptions.IgnoreCase|RegexOptions.Compiled);
Match m = r.Match(inputString);
if (m.Success)
{
return m.Groups["body"].Value;
}
else
{
return inputString;
}
}

Regards,
Svend

"Steve Peterson" <fa******@fakemail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi - I'll admit it.. I'm clueless using regular expressions. That's why I was hoping someone could help me out a bit. I need to search an html file and find strings that are between tags. For example, everything in

bewtween
the <body></body> tag. As you well know, this string could span many

lines,
white spaces, tabs, et.... So I need an expression that will match the
<body> tag, ingnore EVERYTHING then match the end </body> tag.

Anyone to the rescue?? :)

Thanks a lot in advance
Steve


Jul 21 '05 #3
Hi Steve,

You could host the Microsoft Web Browser (ShDocVw) and use the Document
Object Model to do the work for you.

In your case it would be
Browser.Document.Body.InnerHtml
(just as it would in Javascript or VbScript).

Regards,
Fergus
Jul 21 '05 #4

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

Similar topics

5
by: Bradley Plett | last post by:
I'm hopeless at regular expressions (I just don't use them often enough to gain/maintain knowledge), but I need one now and am looking for help. I need to parse through a document to find a URL,...
4
by: Neri | last post by:
Some document processing program I write has to deal with documents that have headers and footers that are unnecessary for the main processing part. Therefore, I'm using a regular expression to go...
10
by: Lee Kuhn | last post by:
I am trying the create a regular expression that will essentially match characters in the middle of a fixed-length string. The string may be any characters, but will always be the same length. In...
3
by: James D. Marshall | last post by:
The issue at hand, I believe is my comprehension of using regular expression, specially to assist in replacing the expression with other text. using regular expression (\s*) my understanding is...
7
by: Billa | last post by:
Hi, I am replaceing a big string using different regular expressions (see some example at the end of the message). The problem is whenever I apply a "replace" it makes a new copy of string and I...
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...
3
by: Zach | last post by:
Hello, Please forgive if this is not the most appropriate newsgroup for this question. Unfortunately I didn't find a newsgroup specific to regular expressions. I have the following regular...
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...
3
by: Mr.Steskal | last post by:
Posted: Wed Jul 11, 2007 7:01 am Post subject: Regular Expression Help -------------------------------------------------------------------------------- I need help writing a regular...
18
by: Lit | last post by:
Hi, I am looking for a Regular expression for a password for my RegExp ValidationControl Requirements are, At least 8 characters long. At least one digit At least one upper case character
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.