Results 1 to 3 of 3

Thread: PCRE and preg_replace

  1. #1
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default PCRE and preg_replace

    Hi,

    another PCRE question for you. This is not important either. is there a way to replace a whitespace with a whitespace? for example

    PHP Code:
    $string="today is";
    preg_replace("/\s/","/\s/",$string);
    echo 
    $string
    what I am getting when I echo the string is: today/\s/is

    This is a low priority question for me. I am just curious

    Thanks for reading!

  2. #2
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by james438 View Post
    PHP Code:
    $string="today is";
    preg_replace("/\s/","/\s/",$string);
    echo 
    $string
    The second argument to preg_replace is a formatted string, not a regular expression-containing string. Use literal white space in the second argument.

    Hope that helps
    Mike

  3. #3
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    yep, cool, thanks. I was wondering why it wasn't replacing a regular expression string with another one.

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
  •