Help with a regex search

Hi there, I have a requirement to search for the following variations and return an array. The preg_split function is perfect, however its the pattern I need help for. Basically, I will have a long strring with some html comments in there with a specific tag contained, eg:
<!-- <<[MYTAG]>> -->

However, as there may be other comments in there eg:

<!-- <<[MYTAG]>> This has some extra text -->
 or
<!-- Some more text here <<[MYTAG]>> And more here.

However I need the whole comment to be the split point. The important bits are <!-- <<[MYTAG]>> -->

Any one got ideas on how I would go about that?
LVL 11
SlimshaneeyAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
ddrudikConnect With a Mentor Commented:
if you don't have nested comments:
/<!--(?:(?!-->).)*-->/s

Open in new window

0
 
mrjoltcolaConnect With a Mentor Commented:
Something like this. I did not test it.

<!--(.*?)<<\[(\w+)\]>>(.*?)-->


Tag name will be in $2
0
 
ddrudikConnect With a Mentor Commented:
if you want to match your specific tag within a non-nested comment.
/<!--(?:(?!-->).)*<<[MYTAG]>>(?:(?!-->).)*-->/s

Open in new window

0
All Courses

From novice to tech pro — start learning today.