Page 1 of 1

Template Blocks.

Posted: Mon Oct 17, 2005 9:10 pm
by Afterlife(69)
Hi, im making a template system and having a little trouble with the regex.

Code: Select all

$pattern = "|(<!-- START $blkName -->)(.*)(<!-- CLOSE $blkName -->)|";
this is my regex to find the blocks but its not working when i put new lines.

This is the style that won't work.

Code: Select all

<!-- START myBlock -->
	<!-- START nesting.myBlock -->
	Text<br />
	<!-- CLOSE nesting.myBlock -->
<!-- CLOSE myBlock -->
Where if i use this it will.

Code: Select all

<!-- START myBlock --><!-- START nesting.myBlock -->Text<br /><!-- CLOSE nesting.myBlock --><!-- CLOSE myBlock -->
Please reply soon.
~AL69

Posted: Mon Oct 17, 2005 9:57 pm
by feyd
your pattern's usage of the any metacharacter does not match across separate lines automatically. Use the s pattern modifier. If you plan to have more than one of these blocks, you may want to also use an ungreedy pattern such as .*? instead of .*

Posted: Mon Oct 17, 2005 11:37 pm
by Afterlife(69)
Ok, thanks could you just give a little bit of an example of how i would use s im new to regex lol

Posted: Tue Oct 18, 2005 5:47 am
by feyd