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


In reply to Regex lookahead, lookbehind by rahulme81

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.