Ask Your Question
0

What is the regular expression that can be used to find all non-PDF files under a file path with a specific string, while excluding folders?

asked 2021-10-20 11:00:00 +0000

huitzilopochtli gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2022-01-24 10:00:00 +0000

nofretete gravatar image

The regular expression that can be used to find all non-PDF files under a file path with a specific string, while excluding folders could be:

^(?!.*\/)[^.]+.((?i)(?

This regex will match any filename that does not have "pdf" as its file extension, does not start with a forward slash character "/" (to exclude folders), and contains the specific string that you are looking for.

Here's a breakdown of how the regex works:

  • ^(?!.*/): Asserts that the match starts at the beginning of the string and that there is no forward slash character "/" before the filename (negative lookahead).
  • [^.]+.: Matches one or more characters that are not a period, followed by a literal period character "." (to match the file extension).
  • ((?i)(?
  • [^.]+$: Matches one or more characters that are not a period until the end of the string (to match the filename).

Note that the specific string that you are looking for should be inserted into the regex where appropriate, replacing the "(?i)" in the regex.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-10-20 11:00:00 +0000

Seen: 7 times

Last updated: Jan 24 '22