SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    Your Lord and Master, Foamy gold trophy Hierophant's Avatar
    Join Date
    Aug 1999
    Location
    Lancaster, Ca. USA
    Posts
    12,305
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    In PHP what would the regular expression be to remove all punctuation from a string?

    .,<>/?:;"'{[}]\|`~!@#$%^&*()-_=+
    Wayne Luke
    ------------


  2. #2
    SitePoint Evangelist
    Join Date
    Jul 2000
    Location
    Warwickshire, England
    Posts
    557
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Perhaps it would be easier to just exclude everthing but letters, numbers?

    ereg_replace( "[^A-Za-z0-9 ]", "", $something);

    <edit>
    You will probably want to keep spaces aswell
    </edit>
    <Edited by PeterW on 12-28-2000 at 12:00 PM>

  3. #3
    Your Lord and Master, Foamy gold trophy Hierophant's Avatar
    Join Date
    Aug 1999
    Location
    Lancaster, Ca. USA
    Posts
    12,305
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I will try that and no I don't want to keep spaces.

    Spaces and some Punctuation are not allowed in IRC nicks.
    Wayne Luke
    ------------


  4. #4
    SitePoint Evangelist
    Join Date
    Jul 2000
    Location
    Warwickshire, England
    Posts
    557
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ahh.. I see.. a secret new project

    ereg_replace( "[^A-Za-z0-9]", "", $something); - for no spaces.


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
  •