Got more questions? Find advice on: ASP | SQL | XML | Windows
in Search
Welcome to RegexAdvice Sign in | Join | Help

only the word coming after a value (PHP)

Last post 08-26-2008, 5:06 PM by sayim. 4 replies.
Sort Posts: Previous Next
  •  08-24-2008, 4:29 PM 45590

    only the word coming after a value (PHP)

    Hi,

    I am learning regex nowadays.

    Now, i am stuck because i cant find how to do it anywhere.

    I need to retrieve a word coming after a value.

    For example, i need to retrieve the value of the PPFT below:

    <input type="hidden" name="PPFT" id="i0327" value="Bzaq!PNfKOXaeEykJDvDZU*lw*ihQKtlNElwUmyEuiJga2DKjiBg2Mma6qXAuRj9hQLoUH4MOmaMqpCrGZmrS4A0cYznoFr10OAfAB4bOVjyaMhNLsZEnH15WhJVa5hWvRZIYSDRjzdF!ieyWG!0spOGl!sHTsTzqq4Hn77XFh8BjYc7vH6v1iObQaK8"/>
     
    Thanks for your time, 

     

    Filed under: ,
  •  08-24-2008, 4:58 PM 45591 in reply to 45590

    Re: only the word coming after a value (PHP)

    What do you want to retrieve with regex specifically?

    How is the PFFT value sent to the PHP script? (FORM POST, etc.)

    There are a number of other non-regex ways to get this value.


  •  08-24-2008, 5:03 PM 45592 in reply to 45591

    Re: only the word coming after a value (PHP)

    I already got this whole PPFT source code (curl) and the value is changin every time.

    So, all i need is the value of PPFT.

  •  08-24-2008, 5:12 PM 45593 in reply to 45592

    Re: only the word coming after a value (PHP)

    <?php
    $sourcestring="your source string";
    preg_match_all('/<input\s[^>]*name="PPFT"[^>]*value="([^"]*)/',$sourcestring,$matches);
    echo "<pre>".print_r($matches,true);
    ?>

    $matches[1] if your target array.

    if you use preg_match:

    <?php
    $sourcestring="your source string";
    preg_match('/<input\s[^>]*name="PPFT"[^>]*value="([^"]*)/',$sourcestring,$matches);
    echo "<pre>".print_r($matches,true);
    ?>

    $matches[1] is your target.


  •  08-26-2008, 5:06 PM 45667 in reply to 45593

    Re: only the word coming after a value (PHP)

    You are the man!.. Yes

    It solved my problem.

    Thanks a lot..

View as RSS news feed in XML