How to pick the work usin开发者_运维百科g RegEx
|=|3|=|5|=|5|=|3|=|Yes|=|gdfsgsdf
i want to pick yes from the
|=|3|=|5|=|5|=|3|=|Yes|=|gdfsgsdf
Can u tell me the preg match regular expression for the above collection ?
Try:
$tokens = explode('|', '|=|3|=|5|=|5|=|3|=|Yes|=|gdfsgsdf');
echo $tokens[10];
See: http://php.net/manual/en/function.explode.php
EDIT
Bharanikumar:
maximum it is before of the last , that is |=|Yes|=|gdfsgsdf
Okay, I believe you mean that you're looking for the token before the last token. If so, try:
$tokens = explode('|=|', '|=|3|=|5|=|5|=|3|=|Yes|=|gdfsgsdf');
echo $tokens[sizeof($tokens)-2];
Note that this assumes you have at least 2 tokens in your string.
And as PP pointed out, |=|
is probably your delimiter.
精彩评论