View Single Post
  #2 (permalink)  
Old May 14th, 2006, 02:33
grahame grahame is offline
Reputable Member
Join Date: Jul 2005
Location: Melksham, Wilts, UK
Posts: 293
Thanks: 0
Thanked 0 Times in 0 Posts
Re: perl tricky pattern matching

There is no concept of nearly matching with regular expressions, but you could match each part conditionally and see how many are missing:

Code: Select all
$string ='LPSTEOPRTRYERTRETR';
@mat = $string =~ /^(LP)?([SKTAQEHLDN])?([TA])?([GN])?([EDASTV])?/;
$count = grep(/^$/,@mat);
print ("$count missing element(s)\n");
-- Graham
Reply With Quote