If you want the quantifier to affect a sequence of characters, enclose those characters in parentheses.
The quantifiers are:
| {n} | Must occur exactly n times |
| {n,m} | Must occur at least n times but no more than m times |
| {n,} | Must occur at least n times |
| * | 0 or more times (same as {0,}) |
| + | 1 or more times (same as {1,}) |
| ? | 0 or 1 time (same as {0,1}) |
![ACCCC[AG][AG][AG]GTGT](con_seq.gif)
if ($a =~ /ACCCC[AG][AG][AG]GTGT/) {...};
With quantifiers:
if ($a =~ /AC{4}[AG]{3}(GT){2}/) {...};
#!/usr/local/bin/perl
print "Please enter date and time, as in \"08-OCT-1997 16:30\"\n";
my $entry = <STDIN>;
chop ($entry);
if ($entry =~ /\d{2}-\w{3}-\d{4} \d{2}:\d{2}/) {
print "good!\n";
} else {
print "wrong format!\n";
}
if ($seq =~ /(GATA){2,}/) { }
# note that we enclosed the sequence to be repeated in parentheses
if ($entry =~ /GDB:\d+/) { }
# i.e. "GDB:" followed by one or more digits
if ($sentence =~ /colou?r/) { }
# the question mark here denotes an optional "u"
For example, < TITLE > and <\tTITLE> mean the same as <TITLE>.To check whether an HTML text contains the TITLE tag, write:
if ($text =~ /<\s*TITLE\s*>/) { }
# the word "TITLE" may optionally be surrounded by any number
# of spaces, tabs etc.