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

Posted by yawnmoth on 07/27/06 07:27

vito wrote:
> I'm processing the following sequence with length more than 100k
>
> 1 cagatgctga taaaaaagtg tgttcctcat agcatttatt taattgaaat atttcaagaa
> 61 cttgaatgta ctaaaaattg agacaaacag tagcaaatca taaaaaaaaa ttgaagtgaa
> 121 ttttacaact ggattcatgt gcctaatatt ttcattggga agtggattca tgtttaacat
> 181 ttccattggg <snippet>
>
> i wrote a program
>
> <?php
> session_start();
>
> if (isset ($_POST['seq']) )
> $seq = $_POST['seq'];
> else
> $seq= $_GET['seq'];
>
> $seq = preg_replace("/[\s\r\n0-9]/", "", $seq);
> echo $seq;
>
> ?>
>
> but it generates an output of fragmented sequences (i.e. partially processed
> result), what is the problem?
To quote from php.net's "Pattern Syntax" article:

"By default, a whitespace character (eg. \s) is any character that the
C library function isspace() recognizes, though it is possible to
compile PCRE with alternative character type tables. Normally isspace()
matches space, formfeed, newline, carriage return, horizontal tab, and
vertical tab."

Per that, including \r and \n in the class definition is redundant.

Anyway, what you should get with the code you wrote is an uninterupted
sequence of a, g, t, and c's. What would you get had you provided the
above sequence? And what's the output that you want?

 

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

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