Path: news.mathworks.com!not-for-mail
From: "jay vaughan" <jvaughan5.nospam@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: find near palindromes with regexp?
Date: Sat, 12 Jul 2008 00:26:03 +0000 (UTC)
Organization: harvard
Lines: 23
Message-ID: <g58tmr$10j$1@fred.mathworks.com>
Reply-To: "jay vaughan" <jvaughan5.nospam@gmail.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1215822363 1043 172.30.248.37 (12 Jul 2008 00:26:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 12 Jul 2008 00:26:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1215048
Xref: news.mathworks.com comp.soft-sys.matlab:478950



Hi,

I am trying to find palindromes and near palindromes within
text strings using regular expressions. I used a regexp from
the Matlab help to get 

test = 'aaaaCDEFGGFEDCbbbbbJKLMNOaabbONMLKJaaaa';
P = regexp(test,'(.{3,13}).?(??@fliplr($1))','match');

which correctly gives P = 'CDEFGGFEDC'.

I would also like to be able to find the near palindrome
starting with JKL. By near palindrome I mean something like
JKLMNOaabbONMLKJ where the aabb part may be two or more
nonpalindromic characters. Unfortunately, I think my regular
expression Kung Fu is too weak to see how to do that. Anyone
out there know a simple way to do this?

Thanks,
J