in reply to Re: restrict use of regex module in script
in thread restrict use of regex module in script
Thank you for your answers. OK, so this was very simple once I tried it out on a very small piece of code instead of what I was working on. I did not realize that you could just stick {} pretty much anywhere you want. Example below, in case anyone is interested.
#!/usr/bin/perl use strict; use warnings; use re::engine::TRE max_cost => 5; my $seq1 = "TTTTACGAGAGAATATGTTAGGTGAAGGAACCTCTATCTGAGAGAAAAA"; my $seq2 = "TTTTGAGCTCGTTGTCGATCCGAGGTACTTTTGAATCCGCAGTTTCTTG"; if ("A pearl is a hard object produced ..." =~ /\(Perl\)/i) { print "$1\n"; } if (($seq2 =~ /GTTGTTCGATCCAGGTAC/) && ($seq1 =~ /ACGAGAGATAGATGA/)) { print "Have a match\n"; }
This will print 'pearl' and "Have a match".
#!/usr/bin/perl use strict; use warnings; my $seq1 = "TTTTACGAGAGAATATGTTAGGTGAAGGAACCTCTATCTGAGAGAAAAA"; my $seq2 = "TTTTGAGCTCGTTGTCGATCCGAGGTACTTTTGAATCCGCAGTTTCTTG"; if ("A pearl is a hard object produced ..." =~ /\(Perl\)/i) { print "$1\n"; } { use re::engine::TRE max_cost => 5; if (($seq2 =~ /GTTGTTCGATCCAGGTAC/) && ($seq1 =~ /ACGAGAGATAGATGA/)) { print "Have a match\n"; } }
This will only print out "Have a match".
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: restrict use of regex module in script
by stevieb (Canon) on Apr 07, 2017 at 23:08 UTC | |
by AnomalousMonk (Archbishop) on Apr 08, 2017 at 00:02 UTC | |
by stevieb (Canon) on Apr 08, 2017 at 00:37 UTC | |
by BillKSmith (Monsignor) on Apr 08, 2017 at 12:20 UTC | |
by pmpmmpmp (Novice) on Apr 11, 2017 at 21:52 UTC |