Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Regular expressions - "negating" a matching string

  • 25-06-2007 3:25pm
    #1
    Registered Users, Registered Users 2 Posts: 1,127 ✭✭✭


    I want to search and return files from a filesystem, that DONT contain a particular string. I need a little help.

    My regex sucks, but I assumed that it would be something like !^foo or something like that?

    am I way off?


Comments

  • Moderators, Science, Health & Environment Moderators Posts: 10,088 Mod ✭✭✭✭marco_polo


    I want to search and return files from a filesystem, that DONT contain a particular string. I need a little help.

    My regex sucks, but I assumed that it would be something like !^foo or something like that?

    am I way off?

    I think [^foo] would work to exclude this string. To the best of my limited knowledge on this subject the square brackets are important. I think ^foo without the brackets would match "foo" only if it occurs at the beginning of a line.


  • Subscribers Posts: 4,076 ✭✭✭IRLConor


    grep -Lr foo dir
    

    will recursively search the directory dir and print the names of the files which do not match the regex foo.

    What tool/language are you using?

    [^foo] will not do it, that matches a single character which is anything except 'f' or 'o'.


  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes




  • Closed Accounts Posts: 97 ✭✭koloughlin




Advertisement