PHP & Regular expression: keyword just occurs once

Posted by lauthiamkok on Stack Overflow See other posts from Stack Overflow or by lauthiamkok
Published on 2011-01-16T15:49:18Z Indexed on 2011/01/16 15:53 UTC
Read the original article Hit count: 245

Filed under:
|
|

Hi,

how can I make sure a certain keyword just occurs once in the input with regular expression?

I think there is some mistakes in the expression below as I can repeat the same keywords,

if (!preg_match('/\b(.php?){1}\b/', $cfg_path))
    {
        $error = true;
        echo '<error elementid="cfg_path" message="PATH - make sure you have a \'.php?\' in the path."/>';
    }

I just want this to be true,

form.php?category=something or form.php?

but not this,

form.php?.php?category=something or form.php?.php?

please let me know how to fix it.

thanks.

© Stack Overflow or respective owner

Related posts about php

Related posts about regex