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

regex to return just body of HTML responseText

Mel
I just need the content between <bodyand </bodyof a message

How can i do this from http_request.responseText string ?

thanks

Jul 30 '07 #1
2 1581
Peter Michaux <pe**********@gmail.comwrote:
On Jul 30, 9:41 am, Peter Michaux <petermich...@gmail.comwrote:
>On Jul 30, 9:37 am, Mel <MelHer...@gmail.comwrote:
I just need the content between <bodyand </bodyof a message
I didn't see the subject line of your post at first. Won't this work?

/<body>(.)</body>/
You mean apart from the unescaped slash in the middle of the regex, the
fact that a dot only matches 1 character, and also that a dot won't match a
newline?

This would probably work most of the time:

/<body[^>]*>((?:.|\n)*)<\/body>/
Jul 30 '07 #2
On Jul 30, 10:03 am, Duncan Booth <duncan.bo...@invalid.invalid>
wrote:
Peter Michaux <petermich...@gmail.comwrote:
On Jul 30, 9:41 am, Peter Michaux <petermich...@gmail.comwrote:
On Jul 30, 9:37 am, Mel <MelHer...@gmail.comwrote:
I just need the content between <bodyand </bodyof a message
I didn't see the subject line of your post at first. Won't this work?
/<body>(.)</body>/

You mean apart from the unescaped slash in the middle of the regex, the
fact that a dot only matches 1 character, and also that a dot won't match a
newline?
Of course :) I suppose I was trying to figure out what is abnormal or
tricky about this RegExp question.

Peter
This would probably work most of the time:

/<body[^>]*>((?:.|\n)*)<\/body>/

Jul 30 '07 #3

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

Similar topics

5
by: Markus Ernst | last post by:
Hello I have a regex problem, spent about 7 hours on this now, but I don't find the answer in the manual and googling, though I think this must have been discussed before. I try to simply...
1
by: kevin | last post by:
I am trying to strip the outermost html tag by capturing this tag with regex and then using the string replace function to replace it with an empty string. while stepping through the code, RegEx...
4
by: Greg -- | last post by:
Is it possible to replace html codes, such as $#63;, to the ASCII equivalent with RegEx? Using RegEx, I'm able to obtain the 63, but I'm unable to convert it: Regex.Replace("?", "&#(.+?);",...
1
by: Maya | last post by:
Hello, Im trying to retrieve a text between the <body> and </body> tags in an HTML file using this code: public string ReadContentsFromPage(string sb) { Regex S = new...
3
by: jab3 | last post by:
Hello. I"m new to this group, and to JavaScript in general, so please forgive me if I breach local etiquette. I'm trying to implement some client-side 'dynamic' validation on a form. I'm having...
11
by: Steve | last post by:
Hi All, I'm having a tough time converting the following regex.compile patterns into the new re.compile format. There is also a differences in the regsub.sub() vs. re.sub() Could anyone lend...
1
by: Karch | last post by:
If you run this: string result = "<html><head></head><body>The body</body></html>"; result = retainBody.Replace(result, "$1"); With the following Regex: private static readonly Regex...
12
by: Justn226 | last post by:
anyone have any idea why i am not getting any return values? it will return the words just not the numbers? HTML <HTML> <head> <title>Zellers Carpeting Cost Estimate</title> </head> ...
3
by: noon | last post by:
I'm runing an xmlHttpRequest to get the site's source code and then applying the regex xhr.responseText.split(/<body*>((?:.|\n)*)<\/body>/i) Works for google.com. Fails on yahoo.com and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
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?
0
marktang
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,...
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...

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.