[eluser]J. Pavel Espinal[/eluser]
Hi there,
Although that is
not a CI specific question, I'll keep the collaborative spirit of CI's community.
This might serve you as a guide:
Code:
/* @var $lsSubject string */
$lsSubject = 'some different string every time where my need is missing in this strange string';
/* @var $lsLftLimit string */
$lsLftLimit = 'string';
/* @var $lsRgtLimit string */
$lsRgtLimit = 'missing';
/* @var $lsPattern string */
$lsPattern = '/'.$lsLftLimit .' (.*) '. $lsRgtLimit.'/';
if(@preg_match($lsPattern, $lsSubject,$laMatches) == 0)
{
// Pattern not found... do whatever you want here
}
else {
print_r($laMatches);
}
// Output:
// Array
// (
// [0] => string every time where my need is missing
// [1] => every time where my need is
// )
// The second element of the $laMatches array should have your desired result.