I need to replace text starting with ‘Title:’ and ending with ‘Article Body:’ using preg_replace or other way. Replaced text will not be contain above quoted words.
eg:
Title:
sample text 1
Article Body:
sample text 2
Should output only
sample text 2
How can I do this with php?
Use positive/negative lookaheads.
The above regex will replace whatever is inside Title: … Article Body: with \nTest\n
Explanation :