Jump to content
WorldDrknss

Matching between comment lines

Recommended Posts

I'm trying to match

<!-- FOR 5 -->

Some HTML content 

<!-- END FOR -->

Using preg_match

\<\!\-\- FOR (\d+) \-\-\>(.*)\<\!\-\- END FOR \-\-\>

Doesn't work since they are on different lines. 

 

Share this post


Link to post
Share on other sites

First you need to learn that < ! - > are not special characters. Escaping them with backslashes makes you look a bit silly.

Then learn about the /x and /s flags. One of them is what you need. The other is me trying to trick you into learning something unrelated.

Then test your regular expression with some HTML content that contains two or more of those FOR/END FORs and see what happens.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.