Have you tried playing around with character sets? Something like

$target = 'mevqgn';
$length_target = length $target;
if ( $LS_Val =~ /-{1,2}[$target]{$length_target}/ ) {
   #do something
}

Whether the above would work for you would depend on whether the code can ignore positive matches on $LS_Val = '--mmmqqq' and so forth. It might be worthwhile to look more closely at the data and see whether there are "don't care" cases that you can ignore.

If there are not, then there is a loop approach:

$t = 'mevqgn'; # just to save keystrokes
$x = $LS_Val;
if ( $x =~ /(-{1,2})/ ) {
   $goodSoFar = $1;
   while (length $t and $x =~ /($goodSoFar([$t]))/ ) {
       $goodSoFar = $1;
       $t =~ s/$2//;
   }
   do_Something unless length $t;
}

That's undoubtedly slower than your original approach, but would be more versatile and possibly easier to maintain.

(Neither snippet above has been tested)


Dax T. Games wrote:
I have a list of characters. I need to get a list of all possble sequences of these characters for example. I have a string that consists of '-mevqgn' I need to pattern match any combination of 'mevqgn' with a preceding - or --.
Right now this is what I am doing but it is very ugly and difficult to come up with the combinations and it makes my brain hurt!:
if ($LS_Val =~ /-{1,2}(mevqgn|
emvqgn|evmqgn|evqmgn|evqgmn|evqgnm|
veqgnm|vqegnm|vqgenm|vqgnem|vagnme|
qvgnme|qgvnme|qgnvme|qgnmve|qgnmev|
gqmnev|gmqnev|gmnqev|gmneqv|gmnevq|
mgnevq|mngevq|mnegvq|mnevgq|mnevqg|
nmevqg|nemvqg|nevmqg|nevqmg|nevqgm|
envqgm|evnqgm|evqngm|evqgnm|evqgmn|
)/i)
{
#Do Something;
}
A subroutine that takes the string of characters as an argument and then returns 1 on success and undef on fail would be ideal for my purpose.
Any help is appreciated.
Dax


--
Will Woodhull
[EMAIL PROTECTED]

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to