I was trying to find a pattern for the following scenario:
Lets say i have this string:
someString[code]some code[/code]someString
Now some code can be anything, What i want to get is reserved words (break, class, etc), So for a real scenario this is a string:
someString
[code]
class someClass{}
[/code]
someString
// And again
someString
[code]
class someClass{}
[/code]
someString
So what i was trying to understand is how can i match all the reserved words that between all of the [code][/code] tags.
For example: [code]someReservedWord some text anotherReservedWord[/code]
I only want to match someReservedWord and anotherReservedWord.
I was thinking to use preg_match_all So i can get all reserved words inside each [code][/code] and use PREG_OFFSET_CAPTURE to get their positions,
The only thing i can't figure out is the pattern, if anyone got idea i will be very thankful, Thank you all and have a nice day.