SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2005
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Regular expression help?

    Hi friends,
    Am not sure if this falls under the regular expression category; this is my problem. Lets say i have a string like this:

    Code PHP:
    <input name="edtTotal" size="3" value="[B]12[/B]" type="text">

    i need help to write a php script(a search & replace kind of function), to replace the string for the tag 'value' with any given string irrespective of what is inside the value tag.

    Any help is highly appreciated

    Thanks

  2. #2
    Always learning kigoobe's Avatar
    Join Date
    May 2004
    Location
    Paris
    Posts
    1,565
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You mean, you want to change the value of edtTotal (12) to something else (say, 15) when the form is getting submitted?

  3. #3
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Trivial example. target needs to be 1, 2 or 3 digits.

    PHP Code:
    $var '<input name="edtTotal" size="3" value="12" type="text">';

    $new'value="1001';

    $var preg_replace("/value=\"[\d]{1,3}/",$new$var);

    echo 
    $var


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •