tags:

views:

54

answers:

1

Hi

How to pick the work using 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 ?

+3  A: 

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.

Bart Kiers
The token here appears to be '|=|'
PP