> > I just need the content between <body> and </body> of a message
>
[quoted text clipped - 10 lines]
>
> Peter
I didn't see the subject line of your post at first. Won't this work?
/<body>(.)</body>/
Peter
Duncan Booth - 30 Jul 2007 18:03 GMT
>> > I just need the content between <body> and </body> of 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>/
Peter Michaux - 30 Jul 2007 18:13 GMT
On Jul 30, 10:03 am, Duncan Booth <duncan.bo...@invalid.invalid>
wrote:
> >> > I just need the content between <body> and </body> of a message
>
[quoted text clipped - 5 lines]
> 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>/
Thomas 'PointedEars' Lahn - 31 Jul 2007 10:54 GMT
> [...] Won't this work?
>
> /<body>(.)</body>/
If the infix slash would be escaped, this would work if the body element
was a one-liner with one-non-whitespace-character content :)
You were looking for
req.responseText.match(/<body(?:\s+(?:.|\n)*?)?>((.|\n)*)<\/body>/)[1]
or a backwards-compatible substitute like
req.responseText.match(/<body(\s+[^>]*)?>((.|\n)*)<\/body>/)[2]
PointedEars

Signature
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&&
navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
Thomas 'PointedEars' Lahn - 31 Jul 2007 11:00 GMT
> [...] Won't this work?
>
> /<body>(.)</body>/
If the infix slash would be escaped, this would work if the body element
was a one-liner with one-non-whitespace-character content :)
You were looking for
req.responseText.match(/<body(?:\s+(?:.|\s)*?)?>((.|\s)*)<\/body>/)[1]
or a backwards-compatible substitute like
req.responseText.match(/<body(\s+[^>]*)?>((.|\s)*)<\/body>/)[2]
PointedEars

Signature
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not the
best source of advice on designing systems that use javascript.
-- Richard Cornford, <f806at$ail$1$8300dec7@news.demon.co.uk>