Community
    • Login

    Generic Regex: Find a file that never contains a line that matches a specific expression

    Scheduled Pinned Locked Moved Blogs
    regexgeneric
    1 Posts 1 Posters 1.1k Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • PeterJonesP Offline
      PeterJones
      last edited by

      There are times you want to find out if a file never has a line that matches a specific expression.

      Using Regular Expression mode in the Find in Files dialog, you could use

      • FIND = (?i-s)\A(^(?!DNM).*$\R*)+\z

      Here, DNM means “does not match”, and is any regular expression which should not be found as a complete line anywhere in the file

      Examples

      For example, to find any files that don’t contain George, you would substitute George in for DNM in the expression, (?i-s)\A(^(?!George).*$\R*)+\z , and then run the Find in Files with that find expression. If the file has George, it will not show up in the Find Results. If a file does not contain George, then the first line of the file will show up in the Find Results panel.

      References

      Originally developed in developing generic regex sequences and subsequent discussion

      For other generic expressions, see FAQ Desk: Generic Regular Expression (regex) Formulas

      1 Reply Last reply Reply Quote 1
      • PeterJonesP PeterJones referenced this topic on
      • PeterJonesP PeterJones referenced this topic on
      • PeterJonesP PeterJones referenced this topic on
      • PeterJonesP PeterJones referenced this topic on
      • PeterJonesP PeterJones referenced this topic on

      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

      With your input, this post could be even better 💗

      Register Login
      • First post
        Last post
      The Community of users of the Notepad++ text editor.
      Powered by NodeBB | Contributors