开发者

regular expression for pick the work from the group

开发者 https://www.devze.com 2022-12-20 09:22 出处:网络
How to pick the work usin开发者_运维百科g RegEx =|3|=|5|=|5|=|3|=|Yes|=|gdfsgsdf i want to pick yesfrom the |=|3|=|5|=|5|=|3|=|Yes|=|gdfsgsdf

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号