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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2002
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    help with simple regular expression code

    PHP Code:
    <?php
    $name 
    '@^#@#';
        if(
    ereg("([[:punct:]]+)[[^:alnum:]]"$name)) echo "yes";
    ?>
    ok, im a little stumped on regular expression. what im trying to do above is make sure th $name string contains all punctuation marks and not a single letter or numerial. however, it doesn't. why?

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That seems to be a smilie-code-polluted RegExp indeed... ;)

    I would simply test if a character appears that is not in the "punct" class.

    PHP Code:
    $name '@^#@#';
    if(!
    ereg("[^[:punct:]]"$name)) {
        echo 
    "yes";

    Though I still wonder for which application this would be needed.


  •  

    Posting Permissions

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