Re: Regular Expressions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2007/11/6, Alberto García Gómez <alberto@xxxxxxxxxxxxxxxxx>:
>
> I'm a mess in regular expressions and I make this code:
>
> $link = ereg_replace('&ntilde;','n',$link);
> $link = ereg_replace('&aacute;','a',$link);
> $link = ereg_replace('&eacute;','e',$link);
> $link = ereg_replace('&iacute;','i',$link);
> $link = ereg_replace('&oacute;','o',$link);
> $link = ereg_replace('&uacute;','u',$link);
>
> I ask if is a way to make those lines into a single one but working as
> well as this piece. I'm thinking in increase those lines so will be
> wonderful if I can optimize the code.
>
>
>
> Este correo ha sido enviado desde el Politécnico de Informática "Carlos
> Marx" de Matanzas.
> "La gran batalla se librará en el campo de las ideas"
>

Use str_replace instead of ereg_replace. You don't need regular expressions
there.
Your code is good as it is, one line per string replacemente. Don't mess up
code readability just for the sake of some lousy optimization, it's not
worthy.

----

(in spanish)

Usa str_replace en lugar de ereg_replace. No necesitas expresiones regulares
en este caso.
Tu código está bien así, una línea por reemplazo. No arruines la legibilidad
del código solo por una optimización inútil, no vale la pena.

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux