regex problem

Hi,
I’m having some difficulties with a regex find and replace to remove the html header to the body part.
The problem is that the match function does work, but the replace function doesn’t. Does anyone know what the problem is?

This is an test method:

content = '<html>afdadsf\n<head></head>ad\rfadsfklj<body>testing';
application.output(content.match('<html>[\0-\uffff]*<body>')[0]);
application.output(content.replace('<html>[\0-\uffff]*<body>','test'));

I’m using servoy 2.2

I just posted a reply to an old thread that does what you want.

http://forum.servoy.com/viewtopic.php?t=7939

Hope this helps.

I tried it, but I don’t think that will do it :(

You gave the following solution:

sHTML         = sHTML.replace(/<head>.+<\/head>/,"");        // Strip the whole header

The dot respresents any character expect a new line (\n). And if I edit a field servoy creates linebreak in the header part.

edit:

Never mind, didn’t read the whole post. Stupid me :D :roll:

Please check the last post in that thread. My first code example had problems with multi-line replaces. The last post shows code that does handle those.