#!/usr/bin/perl use warnings; use strict; while (<DATA>) { print "$. ok\n" if /^foo # "foo" _ # followed by "underscore" (?:bar|test) # followed by "bar|test" (bar or tes +t) _ # followed by "underscore" ((?:\w+\.)+) # followed by alhpnum string with # dot at end (like foo10.1.1.1) \1? # followed by one or zero occurences # of same alhpnum string (like # foo10.1.1.1) followed by dot \w{1,10} # followed by 1-10 characters, # containing at least one digit and # one letter and underscore (e.g. # TEST_test, TEST_test2, # TEST1_test2) \.txt$ # ends with .txt /x; } __DATA__ foo_bar_foo10.1.1.1.TEST.txt foo_test_foo10.1.1.1.foo10.1.1.1.TEST_test.txt
To test the condition "at least one digit and one letter and underscore", I'd probably capture the group and test these conditions independently:
/\d/ && /[[:alpha:]]/ && /_/
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
In reply to Re: Regex lookahead, lookbehind
by choroba
in thread Regex lookahead, lookbehind
by rahulme81
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |