Welcome Guest, Not a member yet? Register   Sign In
Simple string task ?! :)
#2

[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.



Messages In This Thread
Simple string task ?! :) - by El Forum - 05-12-2012, 07:55 AM
Simple string task ?! :) - by El Forum - 05-12-2012, 10:20 AM
Simple string task ?! :) - by El Forum - 05-12-2012, 10:26 AM



Theme © iAndrew 2016 - Forum software by © MyBB