in reply to generate regular expression

Another solution might just to generate the regular expression based on the user input. Assuming simple command-line script (or something similar, I didn't see the source of 'users query'. Easily ported to a web-app or something along those lines). You could do something along the lines of:
#!/usr/bin/perl use strict; use warnings; my $regex_cache = {}; die "Usage $0 [CAC <NUM> TTT <NUM>]\n" if ( @ARGV % 2 ); my %input = @ARGV; # Where the input would be : CAC 2 TTT 2 my $data_set = <DATA>; for my $in ( keys %input ) { my $reg_key = "($in)\{$input{$in}\}"; my $reg = $regex_cache->{$in} ||= qr/($reg_key)/s; print "$1\n" if ( $data_set =~ $reg ); } __DATA__ ATCACCACTTCCTGGACACTACCCTAAACCTTTGAGGA AATAACCGCTTTGTTGTTGCGATCGCCTAATAAATATC AGCGTCTTCGTATGATAAACCAATGCGGAAGTACAAAA
Now, much like the other comments in this thread, I'm not really sure what type of order you are looking for in the set. If 2 CAC means 'CACCAC' or 'CAC\w*CAC', etc. Given the fact that I may have missed this, the compilation of the $reg_key can be changed to be something else. Nevertheless, it will still be able to parse the file based of some sort of input, which is what I believe you were generally looking for.

Sorry if I'm way off base here and my input doesn't help, although I certainly hope it does. Good luck!

---hA||ta----
print$_ for(map{chr($_)}split(/\s+/,join(/\B?:\w+[^\s+]/,<DATA>))); __DATA__ 67 111 100 101 32 80 101 114 108

Replies are listed 'Best First'.
Re^2: generate regular expression
by khoueiry (Initiate) on Apr 01, 2006 at 10:12 UTC
    Thanks, I ment by 2 CAC a separated motifs (CAC\w*CAC). I will test that.