Professional Web Applications Themes

#24645 [Opn]: ereg_replace fails to strtolower replaced string - PHP Development

ID: 24645 User updated by: nek at capsule dot org Reported By: nek at capsule dot org Status: Open Bug Type: Regexps related Operating System: Linux -PHP Version: 4.3.2 +PHP Version: 4.3.1 New Comment: sorry, it's php 4.3.1 and not 4.3.2 Previous Comments: ------------------------------------------------------------------------ [2003-07-14 08:37:18] nek at capsule dot org Description: ------------ Hi, i'm trying to replace a portion of string by its strtolowered equivalent see reproduce code and results below : it should give "href=javascript :comment()" but only "HREF" is lowered, not the matching string

Reproduce code: --------------- <?php $newsaff = "<A HREF=\"JAVASCRIPT :COMMENT()\">THIS IS A TEST ...

  1. #1

    Default #24645 [Opn]: ereg_replace fails to strtolower replaced string

    ID: 24645
    User updated by: nek at capsule dot org
    Reported By: nek at capsule dot org
    Status: Open
    Bug Type: Regexps related
    Operating System: Linux
    -PHP Version: 4.3.2
    +PHP Version: 4.3.1
    New Comment:

    sorry, it's php 4.3.1 and not 4.3.2


    Previous Comments:
    ------------------------------------------------------------------------

    [2003-07-14 08:37:18] nek at capsule dot org

    Description:
    ------------
    Hi,

    i'm trying to replace a portion of string by its strtolowered
    equivalent

    see reproduce code and results below : it should give
    "href=javascript:comment()" but only "HREF" is lowered, not the
    matching string \1



    Reproduce code:
    ---------------
    <?php
    $newsaff = "<A HREF=\"JAVASCRIPT:COMMENT()\">THIS IS A TEST LINK</A>";

    $newsaff =
    ereg_replace("HREF=\"([^\"]+)\"",strtolower("HREF=\"\\1\""),$newsaff);

    print $newsaff;
    ?>

    Expected result:
    ----------------
    <A href="javascript:comment()">THIS IS A TEST LINK</A>

    Actual result:
    --------------
    <A href="JAVASCRIPT:COMMENT()">THIS IS A TEST LINK</A>


    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=24645&edit=1[/url]

    nek at capsule dot org Guest

  2. #2

    Default #24645 [Opn]: ereg_replace fails to strtolower replaced string

    ID: 24645
    User updated by: nek at capsule dot org
    Reported By: nek at capsule dot org
    Status: Open
    Bug Type: Regexps related
    Operating System: Linux
    PHP Version: 4.3.1
    New Comment:

    well,

    maybe the matching string should be considered as a normal one, so we
    can use some functions on it.

    this would render ereg_replace function even more powerfull, isn't it ?


    Previous Comments:
    ------------------------------------------------------------------------

    [2003-07-14 09:09:01] b_ulrich at t-online dot de

    Using strtolower("HREF=\"\\1\"") as parameter is like using
    "href=\"\\1\"" directly.
    First the strtolower is processed and then that result is used as
    parameter.

    You have to change your search/replace pattern to get what you want.

    The function works correct.

    ------------------------------------------------------------------------

    [2003-07-14 08:39:01] nek at capsule dot org

    sorry, it's php 4.3.1 and not 4.3.2

    ------------------------------------------------------------------------

    [2003-07-14 08:37:18] nek at capsule dot org

    Description:
    ------------
    Hi,

    i'm trying to replace a portion of string by its strtolowered
    equivalent

    see reproduce code and results below : it should give
    "href=javascript:comment()" but only "HREF" is lowered, not the
    matching string \1



    Reproduce code:
    ---------------
    <?php
    $newsaff = "<A HREF=\"JAVASCRIPT:COMMENT()\">THIS IS A TEST LINK</A>";

    $newsaff =
    ereg_replace("HREF=\"([^\"]+)\"",strtolower("HREF=\"\\1\""),$newsaff);

    print $newsaff;
    ?>

    Expected result:
    ----------------
    <A href="javascript:comment()">THIS IS A TEST LINK</A>

    Actual result:
    --------------
    <A href="JAVASCRIPT:COMMENT()">THIS IS A TEST LINK</A>


    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=24645&edit=1[/url]

    nek at capsule dot org Guest

Similar Threads

  1. "?" in a query string is replaced with a '/'
    By maximo789 in forum Coldfusion - Advanced Techniques
    Replies: 6
    Last Post: March 3rd, 11:26 PM
  2. RegExp that looks for a string and only replaced part of it...
    By Mark Hanford in forum PHP Development
    Replies: 1
    Last Post: July 29th, 04:14 PM
  3. #24645 [Bgs]: ereg_replace fails to strtolower replaced string
    By nek at capsule dot org in forum PHP Development
    Replies: 2
    Last Post: July 14th, 05:00 PM
  4. Replies: 0
    Last Post: July 14th, 02:21 PM
  5. #24645 [NEW]: ereg_replace fails to strtolower replaced string
    By nek at capsule dot org in forum PHP Development
    Replies: 0
    Last Post: July 14th, 01:37 PM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139