in reply to More Power to your Regex

You should see if there is a way you can get these functions into Perl 6. I'm sure that there is space for interesting (and useful) regexes like these that don't require you having to type in something as confusing as /^\W*(?:((.)\W*(?1)\W*\2|)|((.)\W*(?3)\W*\4|\W*.\W*))\W*$/i

Try emailing someone who is working on Perl 6 with your functions. Maybe you could write a module that includes all of these as subfunctions.

Well, good luck with your work. I certainly enjoyed looking it over.

Peace, BlackFlag.

Replies are listed 'Best First'.
Re: Re: More Power to your Regex
by blackflag (Novice) on Apr 02, 2002 at 21:08 UTC
    Well, I just typed up something that you might find interesting, its worth a look at least:

    print "Type a word or phrase: "; $line = <STDIN>; $line =~ s/\W//g; # removes space and nonalphanumerics $line =~ tr/A-Z/a-z/; # converts to lowercase. @letters = split //, $line; $reverse = join "", reverse @letters; # gets the letter and reverse it if(@letters == 1){ print "One letter palindrome, trivial!\n"; } elsif($reverse eq $line){ print "This is a palindrome.\n"; } else{ print "Not a palindrome.\n"; }


    If you have any thoughts about this, be sure to /msg me. However, its much cooler to have a single regex do it than having all those lines of code. Peace... BlackFlag.