regular expression

Discussion in 'Perl Misc' started by giampiero, Sep 24, 2005.

  1. giampiero

    giampiero Guest

    there is a way using regular expression to detect if in a string there
    is a substring and its rotation. es 000012340003412000?
    thanx a lot
     
    giampiero, Sep 24, 2005
    #1
    1. Advertising

  2. giampiero wrote:

    > there is a way using regular expression to detect if in a string there
    > is a substring and its rotation.


    Does this help you ?

    #!perl
    use strict;
    use warnings;
    use String::Substrings;
    my $b='AF452UFA25';
    my @r=();
    my $prev='none';
    my @p=substrings $b;
    my @out=grep($_ ne $prev && ($prev=$_),sort @p);
    for (@out) {
    push @r, $_
    if($b=~/$_/ && $b=~/@{[my $o=reverse]}/ && length>1)
    }

    # small report utility
    print "\nFollowing substrings appear reversed in '$b':";
    print "\n".$_ for @r;

    I'm leaving out substrings that only consist of 1 character (they would
    always be in the result array obviously).

    String::Substrings is at
    http://cpan.uwinnipeg.ca/dist/String-Substrings.

    --
    Bart
     
    Bart Van der Donck, Sep 24, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Keith-Earl
    Replies:
    1
    Views:
    463
    Mary Chipman
    Jun 15, 2004
  2. VSK
    Replies:
    2
    Views:
    2,336
  3. =?iso-8859-1?B?bW9vcJk=?=

    Matching abitrary expression in a regular expression

    =?iso-8859-1?B?bW9vcJk=?=, Dec 1, 2005, in forum: Java
    Replies:
    8
    Views:
    863
    Alan Moore
    Dec 2, 2005
  4. GIMME
    Replies:
    3
    Views:
    11,998
    vforvikash
    Dec 29, 2008
  5. Noman Shapiro
    Replies:
    0
    Views:
    240
    Noman Shapiro
    Jul 17, 2013
Loading...

Share This Page