First, ls | xargs grep <string> makes grep look for occurrences in
contents of files listed by ls, not in list of filenames. To look for
filenames it should be enough to do:
ls | grep '\d{11}-\d\.(?:json|pdf)'
Second, grep '\d{11}-\d\.(?:json|pdf)' would work only with GNU grep
and -P option. Use the following syntax instead - it works with GNU,
busybox and FreeBSD implementations of grep:
ls | grep -E '[[:digit:]]{11}-[[:digit:]]\.(json|pdf)'
Third, parsing ls is not a good
idea. Use
GNU find:
find . -regextype egrep -regex '.*/[[:digit:]]{11}-[[:digit:]]\.(json|pdf)'
or FreeBSD find:
find -E . -regex '.*/[[:digit:]]{11}-[[:digit:]]\.(json|pdf)'