Re: PHP script for detecting pattern sequences?
| From: | WenDong Zhang | Date: | Thu, 09 Jul 2009 03:32:54 +0000 |
| Subject: | Re: PHP script for detecting pattern sequences? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-295062@lists.php.net to get a copy of this message | ||
yes
(\d+?)\1+ works fine
On Thu, Jul 9, 2009 at 6:00 AM, Per Jessen <per@computer.org> wrote:
> Rob Gould wrote:
>
> > Can anyone tell me if there's a PHP library out there that will help
> > me determine "pattern sequences" from a string?
> >
> >
> > Example input:
> >
> > 032258064516129032258064516129032258064516129032258064516129
> > Sequence = 032258064516129
> >
> >
> > 037037037037037037037037037037037037037037037037037037037037
> > Sequence = 037
> >
> >
> > I know regex can help you find a pattern when you know what the
> > pattern is already, but this is different.
>
> Nah, it's the same thing.
>
> A suitable regex might look something like this:
>
> /([0-9]+)\1+/
>
> Not tested, probably won't work on the first try. You may need
> greediness adjustments.
>
>
> /Per
>
>
> --
> Per Jessen, Zürich (14.1°C)
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Best Regards!
Wen Dong