You are here: Re: [PHP] regex and global vars problem « PHP « IT news, forums, messages
Re: [PHP] regex and global vars problem

Posted by Jasper Bryant-Greene on 10/20/63 11:30

On Thu, 2005-10-27 at 00:00 +0200, Jochem Maas wrote:
> gonna jump on your thread there Jasper, I would
> like to comment on your function and ask you a question:
>
> which is 'better' (for what), preg_*() or ereg[i]*()?

I prefer preg_*(), but I used eregi() because I couldn't be bothered
figuring out his regexp (it looked right, and it worked) and that's what
he used :)

It's a matter of personal taste, mainly.

[snip]
> > <?php
> > function fix_mac( $mac ) {
> >
> > if( eregi(
> >
> > "^[0-9A-Fa-f]{2}\-" .
> > "[0-9A-Fa-f]{2}\-" .
> > "[0-9A-Fa-f]{2}\-" .
> > "[0-9A-Fa-f]{2}\-" .
> > "[0-9A-Fa-f]{2}\-" .
> > "[0-9A-Fa-f]{2}$",
>
> this string concatenation looks a bit naff.
> although on second thoughts I can see why you did it this way.
> down to personal choice :-).

I don't like it either, but that bit already worked, so I left it
functionally as-is, and I had to make it shorter so as to not wrap
stupidly in the email.

> the use of double quotes means strictly speaking
> you should be escaping the backslash and dollar sign (and the
> parentheseses?) although i would recommend single quotes.

Agreed.

> I would have used preg_match(), something like
[snip]

So would I, if I had been writing the function from scratch.

> white space is nice but too many blank lines lead to overscroll ;-)

Another matter of personal taste. I love whitespace and my scroll wheel
has its acceleration turned up very high, so scrolling doesn't really
bother me :)

--
Jasper Bryant-Greene
General Manager
Album Limited

e: jasper@album.co.nz
w: http://www.album.co.nz/
b: http://jbg.name/
p: 0800 4 ALBUM (0800 425 286) or +64 21 232 3303
a: PO Box 579, Christchurch 8015, New Zealand

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация