Hi there,

You are correct that I am stupid to call the manual bad, it was not meant
like that. It was that it was not suited to me, and that I actually just
wanted to find a solution to my problem directly, and it did not give me
that. I have never worked with Regular Expressions before, so I might need
to do some more research on that, it seams to be a good tool :)

I will do some testing in the CMD to learn how to use it, should not be that
big of a deal :)

Many times the regex looks like rubbish, but that is just because I do not
know the "language" :)

Thanks,
Peter


-----Original Message-----
From: Jochem Maas [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 09, 2006 6:06 PM
To: Peter Lauri
Cc: php-general@lists.php.net
Subject: Re: [PHP] preg_match

Peter Lauri wrote:
> Hi,
> 
>  
> 
> How do I add so that it checks for a comma , in this preg_match. I think
the
> documentation is not that good for the pref_match:

it's a lot better than you spelling of preg_match. the subject of regexps is
very
complex, the documentation reflects that - but to call them 'not that good'
is
rather a disservice to the people that wrote them imho.

I taught myself regexps primarily using the php docs -
which is a testament to how good they are. :-)

> 
>  
> 
> preg_match('/^[a-z0-9-_\'() +]*$/i', $s);


$q = chr(39); // makes for easier cmdline testing !?E#$@
function test($s) {
        global $q;
        echo "\"$s\" is ",(preg_match("#^[a-z0-9\\-_\\$q\\(\\), \\+]*$#i",
$s)?"true":"false"),"\n";
        // I escaped everything char that has special meaning in a regexp
        // backslashes are themselves escaped in double quotes strings.
        // I used different regexp delimiters (#) - just my preference
}

test("foo");
test(",");
test("()");
test("(123)");
test("(123,456)");
test("(+123,456)");
test(" (+123,456) ");
test(" $q(+123,456) $q");

> 
>  
> 
> /Peter
> 
>  
> 
>  
> 
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to