True. It could get hairy. Unicode is a pretty vast landscape, and I think if you only want ASCII word characters to count as things that could be in a filename, your original [A-Za-z0-9_] is your best bet. Thanks to the others for their comments. As Ken says: there are probably more ways to code this.
On Sat, Nov 5, 2016, 11:44 AM Kent Fredric <kentfred...@gmail.com> wrote: > On 6 November 2016 at 06:14, Jovan Trujillo <jovan.trujil...@gmail.com> > wrote: > > > > 1207003PE_GM_09TNPLM2.csv > > > > I originally though m/[A-Za-z0-9\_]+/ would work, but it captures both > > strings. > > So then I tried m/[A-Za-z0-9\_]+(?!\.)/ but I still get both strings > > captured. > > Alternatively, if your use case allows it, it might be more viable to > use negative matching. > > $file !~ /[.]/ and print "$file has no extension" > > There's probably a reason why you're not doing this already, but can't > tell from the context. > > NB: Clearly defining what an "extension" means is also pertinent: > > fooo.csv > fooo.jpg > fooo.jpeg > foo.tar.xz > foo.config > .config > .config.ini > > You probably are just meaning "has a dot" or "has a dot followed by at > most 3 characters", but its hard to tell from context ( and there are > a lot of obvious cases where there is an "extension" suffix that is > greater than 3 characters ) > > > > > > > > -- > Kent > > KENTNL - https://metacpan.org/author/KENTNL > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > >