in reply to Re^3: Regex lookahead, lookbehind
in thread Regex lookahead, lookbehind

Hi choroba ... sorry for the confusion with the post. below is what I am doing.
foo_bar_foo10.1.1.1.foo10.1.1.1.txt foo_bar_foo10.1.1.1.foo10.1.1.1.FOO-1.txt foo_bar_foo10.1.1.1.foo10.1.1.1.test_FOO1.txt foo_bar_foo10.1.1.1.foo10.1.1.1.test_FOO_abc_mon.txt

Above are the files which I need to query with regular expression. Out of which I need to pick only file2, file3, file4

and move them to some other directory. file1 should remain untouched.

Similarly sometime another set of files is as below

foo_foo_foo10.1.1.1.TEST.failed foo_foo_foo10.1.1.1.test_FOO1.failed

Out of which I need to pick only file2 and move them to some other directory. file1 should remain untouched.

As of now I have separte regex to filter and picking the desired files with grep -v.

Thanks

Replies are listed 'Best First'.
Re^5: Regex lookahead, lookbehind
by choroba (Cardinal) on Feb 23, 2017 at 12:18 UTC
    > Out of which I need to pick only file2, file3, file4

    But why? Do you just want to skip the shortest name? If so, use length instead of a regex. Otherwise, try to explain how you select the files to stay or move.

    ($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,