PetaMem has asked for the wisdom of the Perl Monks concerning the following question:
Again, I've stumbled about a "make it more elegant?"-problem: Actually this time it is more a "keep it generic?" type of a problem.
I have a list of strings (words/phrases.) With reverse and a little looping, it is simple to find those, that are symmetric, i.e. spelled forward and backward alike.
The problem is now, that I use a generic regexp-search within this wordlist to find special entries fitting - well - what an regexp can fit.
It would be cool to reuse this regexp search for the forward/backward test, but I don't know how resp. if this is even possible.
My guess is, that it is not possible with an regexp for words of arbitrary length, as this problem seems to be quite similar to that of balanced parentheses. But then again I might be wrong, as this could be a special case.
Enlightenment anyone?
Bye
PetaMem All Perl: MT, NLP, NLU
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Reverse a Word - without reverse??
by Juerd (Abbot) on Mar 07, 2004 at 12:42 UTC | |
|
Re: Reverse a Word - without reverse??
by matija (Priest) on Mar 07, 2004 at 11:44 UTC | |
|
Re: Reverse a Word - without reverse??
by ambrus (Abbot) on Mar 07, 2004 at 16:51 UTC | |
|
Re: Reverse a Word - without reverse??
by Popcorn Dave (Abbot) on Mar 07, 2004 at 20:57 UTC | |
by PetaMem (Priest) on Mar 07, 2004 at 21:42 UTC | |
|
Re: Reverse a Word - without reverse??
by hv (Prior) on Mar 09, 2004 at 17:24 UTC |