You are here: Re: regular expression inquiry « PHP Programming Language « IT news, forums, messages
Re: regular expression inquiry

Posted by Benjamin Esham on 07/27/06 04:43

vito wrote:

> i wrote a program
>
> $seq = preg_replace("/[\s\r\n0-9]/", "", $seq);
>
> but it generates an output of fragmented sequences (i.e. partially
> processed result), what is the problem?

Your regular expression may be giving unexpected results: since the RE is
double-quoted, the \r and \n are converted to their respective special
characters *before* being sent to preg_replace(), while the \s is left to be
processed by preg_replace(). You might try

$seq = preg_replace('/[[:space:]0-9]/', '', $seq);

which sidesteps the issue entirely by using [:space:]. Personally, I would
just use

$seq = preg_replace('/[^acgt]/', '', $seq);

which removes everything except for the characters [acgt]. This will work
no matter what other stuff happens to be present in the input file.

HTH,
--
Benjamin D. Esham
bdesham@gmail.com | AIM: bdesham128 | Jabber: same as e-mail
Más sabe el diablo por viejo que por diablo. (Spanish proverb)

 

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

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