SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2006
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Regular expression

    hi all,
    I am having a problem of reg expression. I would like to validate a string which is without [@#$%^&()] or any character except [-_"]. How I going to achieve that? Thank you.

  2. #2
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Any character except -_"?

    Easy:
    /\A[-_"]*\Z/
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?

  3. #3
    SitePoint Enthusiast
    Join Date
    May 2006
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mnn... I think I have messed up the sentences. Here is what i concern, I would like to have somethings, say "snow05" or snow-05 or snow_05 (Any characters and numeric or either having [-,_,""] ). I do not want to have "&*($%#?" contain in my string. Thanks for provide me some ideas to implement this.

  4. #4
    Chessplayer kleineme's Avatar
    Join Date
    Apr 2004
    Location
    Germany
    Posts
    608
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    preg_match('~^[-_"a-z0-9]+$~i', $string);
    Never ascribe to malice,
    that which can be explained by incompetence.
    Your code should not look unmaintainable, just be that way.


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
  •