SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Enthusiast subduck's Avatar
    Join Date
    Sep 2003
    Location
    USA
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    $5 paypal to the person that can solve this super easy regex problem

    Probably through preg_replace, I need help creating a function that removes all characters in a string excluding the following characters: a-z 0-9 space

    Example:
    $string = 'hello & wo^^rld $ #__sig@@n says% hi!!!
    tes*ti@@ng 012__3
    n**#)@ow';

    output should be:

    hello world sign says hi
    testing 0123
    now

  2. #2
    SitePoint Evangelist AlienDev's Avatar
    Join Date
    Feb 2007
    Location
    UK
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    preg_replace('~[^0-9a-zA-Z ]~', '', $text);
    Me on StackOverflow | Blog & personal website.

    I mostly use: PHP, Java, JavaScript, Android.

  3. #3
    SitePoint Enthusiast subduck's Avatar
    Join Date
    Sep 2003
    Location
    USA
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    pm me your paypal address, that worked perfectly thanks


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
  •