in reply to Complicated regexp problem
This is a variation on stevieb's reply. The optional ftp:// doesn't make much sense unless it's anchored to something; I anchor it with \A absolute-start-of-string. (Update: By the same token, the (?: [^/]+ /){5} five-level-deep directory nesting pattern only makes sense if you specify five levels deep from what. Again, \A is used, but I don't know if this is appropriate to stefanches7 true requirement.)
c:\@Work\Perl\monks>perl -wMstrict -le "my $regexp = qr{ \A (?: ftp://)? (?: [^/]+ /){5} ([a-z_]+) / }xms; ;; my $link = 'ftp://ftp.ensemblgenomes.org/pub/release-36/metazoa/vcf/ixodes_sca +pularis/ixodes_lapuscaris_incl_consequences.vcf.gz'; ;; print qq{captured '$1'} if $link =~ $regexp; " captured 'ixodes_scapularis'
Give a man a fish: <%-{-{-{-<
|
---|
In Section
Seekers of Perl Wisdom