Guif If
Guif If

Reputation: 595

Regext start with 3 consecutive capital letters

Have the following regex to detect a file start with 3 consecutive capital letters:

(?=(.*[A-Z]){3})(?=(.*[a-z]){3})(?=.*(_|[^\w]))

When I search a file I found it:

root@node01:~# find . -type f -name DASD-680.mp4.part
./DASD-680.mp4.part

But when I search didn't found any results:

root@RPI01:~# find . -type f -regextype egrep -regex "(?=(.*[A-Z]){3})(?=(.*[a-z]){3})(?=.*(_|[^\w]))"

What's the exactly problem???

Update:

file exists:

TAD-007.mp4

but no result with this:

/usr/bin/find . -type f -regextype posix-extended -regex "[A-Z]{3}.*"

thanks!

Upvotes: 1

Views: 74

Answers (1)

Toto
Toto

Reputation: 91385

  • find gives list of files prefixed with ./ like ./DASD-680.mp4.part
  • the regex motif must match the whole filename, included ./
  • the regex flavor doesn't support quantifiers

Here is a way to do what you want:

find . -type f -regex '..[A-Z][A-Z][A-Z].*'

where the first 2 dots matches ./

You cal also use:

find . -type f -regex '\./[A-Z][A-Z][A-Z].*'

Upvotes: 2

Related Questions