tags:

views:

44

answers:

1

With a cURL request I load a complete website into a variable: $buffer.

In the source of the site there are two labels in between which my relevant content is placed.

****** bunch of code *******
<!-- InstanceBeginEditable name="Kopij" -->
       this part I want to store in a match
<!-- InstanceEndEditable -->
****** bunch of code *******

I've been messing around with preg_match and its regexp. Can someone try to help me?

Thanx in advance.

//edit The $buffer is this text file: http://www.rp-systeem.nl/rps/code.txt I want to substract 103 to 176

A: 
<?php

$buffer = <<<EOT

****** bunch of code *******
<!-- InstanceBeginEditable name="Kopij" -->
       this part I want to store in a match
<!-- InstanceEndEditable -->
****** bunch of code *******

EOT;

preg_match('/<!-- InstanceBeginEditable name="Kopij" -->(.*)<!-- InstanceEndEditable -->/s', $buffer, $match);

print_r($match[1]);

?>

The above snippet prints (as seen on ideone.com):

   this part I want to store in a match

The part that you want to match is captured as group 1. There's nothing special in the pattern, except that it's in single-line mode so . matches everything (just in case you have multiple lines).

References

polygenelubricants
Thanks this works for 90% it seems that there is some conflict in 'the bunch of code'This is the http://www.rp-systeem.nl/rps/code.txt I would love to match lines 103 to 176
richardverbruggen
@richardverbruggen: If there are a bunch of `InstanceEndEditable`, then greedy `(.*)` won't work, so use the reluctant `(.*?)` instead (see http://ideone.com/UH599)
polygenelubricants