I have a text like that
[CONTENT][SECTION]This is the section C #1[/SECTION][SECTION]This is the section C #2[/SECTION][SECTION]This is the section E #3[/SECTION]
and I try to match each section, including the section tags with that expression :
\[SECTION\][^SECTION]+(SECTION\])
but the above code does not work because the [^SECTION] is looking in the text between the start and end tags for any character that is not S, E, C, T, I ,O and N
Any idea on how to solve that issue ?
I am using PHP to match the tags and it’s contents with preg_match_all(); And I like to match each section one by one, and not all the sections at once.
I think this is what you want, getting the text for the contents of a single SECTION?
The
?makes the*lazy, so it will only match up to the first[/SECTION]from the current one.Example:
Result: