rahulme81 has asked for the wisdom of the Perl Monks concerning the following question:
Happen to come across Regex lookahead, lookbehind and atomic groups in perl, though not very expert to use in first try.
Got a thought - If I can match a string name within a single regular expression with this concept
So I can avoid using multiple match patterns to deal with something required on this matches within my program
My search patterns looks like as below :
foo_bar_foo10.1.1.1.TEST.txt foo_test_foo10.1.1.1.foo10.1.1.1.TEST_test.txt
"foo"
1. followed by "underscore"
2. followed by "bar|test" (bar or test)
3. followed by "underscore"
4. followed by alhpnum string with dot at end (like foo10.1.1.1)
5. followed by one or zero occurences of same alhpnum string (like foo10.1.1.1)
6. followed by dot
7. followed by 1-10 characters, containing at least one digit and one letter and underscore (e.g. TEST_test, TEST_test2, TEST1_test2)
8. ends with .txt
Thanks in advance
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex lookahead, lookbehind
by Discipulus (Canon) on Feb 23, 2017 at 08:04 UTC | |
by rahulme81 (Sexton) on Feb 23, 2017 at 09:26 UTC | |
by AnomalousMonk (Archbishop) on Feb 23, 2017 at 16:26 UTC | |
|
Re: Regex lookahead, lookbehind
by choroba (Cardinal) on Feb 23, 2017 at 06:19 UTC | |
by rahulme81 (Sexton) on Feb 23, 2017 at 09:25 UTC | |
by choroba (Cardinal) on Feb 23, 2017 at 10:04 UTC | |
by rahulme81 (Sexton) on Feb 23, 2017 at 11:40 UTC | |
by choroba (Cardinal) on Feb 23, 2017 at 12:18 UTC | |
by haukex (Archbishop) on Feb 23, 2017 at 10:33 UTC |