|
Posted by Schraalhans Keukenmeester on 05/12/07 11:57
At Thu, 10 May 2007 20:05:32 -0700, adzir let his monkeys type:
> On May 8, 1:31 am, Michael Fesser <neti...@gmx.de> wrote:
>> .oO(gosha bine)
>>
>> >Michael Fesser wrote:
>>
>> >> preg_match('#[a-zA-Z\d]*[A-Z][a-zA-Z\d]*#', $str);
>>
>> >Michael, your pattern will also match "*&(*%& Z #)&*(", because it's not
>> >anchored. Use ^ and $ (and not forget /D) to make it do what you want.
>>
>> Correct. Good point.
>>
>> Micha
>
> Where can I find a good site to explain to me all the syntax (simbols,
> characters used in the preg_match function)?
>
> php.net seems not to satisfy me.
Kudos! Now *that's* the question so many fail to ask. The detours people
will take just to avoid learning the ropes with regex, unbelievable.
It _has_ a fairly steep learning curve and a level of abstraction that
requires concentration and focus, but the merits are well worth the effort
imho.
One catch (from my own experience): try to keep an open mind as to
what solution is needed in a given situation. Some code is full of regex
fixing stuff that could (should?!) easily be dealt with using normal
string functions. Often easier to follow/adapt (for you and future editors
of your code, good documentation explaining what your regex does is key.)
and less resource-hungry. A complex regular expression can be quite taxing
on your server.
The 'best' excuse found here to avoid the matter in the NG undoubtedly
was: "I don't trust regex!".
There are several sites that offer, besides explanation, on- or offline
utilities allowing you to experiment with regex on the fly. Be aware of
the subtle dialect differences between different regex flavours though. It
may prevent you from going ape at some point...
Good luck learning regex. You'll soon reach the point where you start
wondering how you ever managed without.
Sh.
[Back to original message]
|