I would like to use PHP to input a certain text and the output should be the text in between two words. To clarify:
Input:
Lorem ipsum dolor sit amet
Output:
dolor sit
In the Cell box, select a cell where you want to extract the text (here I select cell B5); In the Start char(s) box, enter the start word of the two words you want to extract all text strings after it; In the End char(s) box, enter the end word of the two words you want to extract all text strings before it.
How do I extract text between two words ( <PRE> and </PRE> ) in unix or linux using grep command? Let us see how use the grep command or egrep command to extract data between two words or strings. I also suggest exploring sed/awk/perl commands to extract text between two words on your Linux or Unix machine.
$str = 'Lorem ipsum dolor sit amet';
$word1 = 'ipsum';
$word2 = 'amet';
preg_match('/'.preg_quote($word1).'(.*?)'.preg_quote($word2).'/is', $str, $match);
// result would be in $match[1]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With