Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Dec 2006
    Posts
    306
    Thanks
    24
    Thanked 0 Times in 0 Posts

    regular expression replace

    Hi;
    i want to have a result like the follwoing by using regular expression
    "锕=錒','锿=鎄','皑=皚','嗳=噯','蔼=藹','霭=靄','爱=愛','嫒=嬡";

    but my code give me not right result, could anyone help, thanks
    "锕=錒 锿=鎄  皑=皚   嗳=噯  蔼=藹  霭=靄  爱=愛   嫒=嬡";
    PHP Code:
    <?php
    $string 
    "锕=錒 锿=鎄  皑=皚            嗳=噯  蔼=藹  霭=靄  爱=愛          嫒=嬡";
    $pattern '/(\s)+/u';
    $replacement '\',\'';
    echo 
    preg_replace($pattern$replacement$string);
    ?>

  • #2
    New Coder
    Join Date
    Feb 2009
    Posts
    38
    Thanks
    0
    Thanked 1 Time in 1 Post
    try this one
    PHP Code:

    <?php  
     $search
    ="  ";  
     
    $replace="','";  
     
    $string="锕=錒  锿=鎄  皑=皚  嗳=噯  蔼=藹  霭=靄  爱=愛  嫒=嬡";  
     echo 
    str_ireplace($search,$replace,$string);  
    ?>
    Last edited by milanchheda; 03-14-2009 at 06:29 AM.

  • #3
    Regular Coder
    Join Date
    Dec 2006
    Posts
    306
    Thanks
    24
    Thanked 0 Times in 0 Posts
    Thanks a lot. works


  •  

    Posting Permissions

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