Menu

Searching Multiple texts inside of files.

Anonymous
2017-03-17
2017-06-23
  • Anonymous

    Anonymous - 2017-03-17

    Hello,

    Im trying to search multiple text in files.

    help file says..
    regexp:cat|dog search for 'cat' or 'dog'
    this works well.

    I need to search with an and operator
    ex: 'cat' and 'dog'

    what is the correct format to do this.
    I tried comma [,] space [ ] but didn't worked.

    Thank You

     
  • jmj

    jmj - 2017-03-17

    Do you want to use regular expressions (regexp), or just happened to find that line?

    If regular expressions are not needed, you can write "+cat,+dog". There are also a help page that describes all searching options, and also there are options (Settings, Advanced tab) that can be used to change behaviour.

     
  • Anonymous

    Anonymous - 2017-03-17

    Sorry, I wasn't clear enough
    I was trying to get some hint about regrex format.

    Im trying to use with command line.
    i want to search file which contains multiple strings
    find files only includes both of these strings, string1 and string2

    locate.exe -i -+ -v -lc:+string1,+string2
    locate.exe -i -+ -v -lR:+string1,+string2

    may i ask for any advice?

     
  • jmj

    jmj - 2017-03-17

    Oh, you are trying to make searches for the content of files, not files names. Such cabapilities are lacking in Locate32 because the main idea of the program is to find file names fast. + and - does not work for the content. It could perhaps be possible to do such searches using regular expression, but I am not familiar with those so well and can't assist that what search term should be used (locate passes regular expressions to PCRE library).

     
  • Chris Smith

    Chris Smith - 2017-08-23

    I created 5 test text files containing the strings 'bird,cat,dog,fish'.
    Then removed test strings in each file. So that:
    bird _,2,3,4,5
    cat 1,_,3,4,_
    dog 1,2,_,4,_
    fish 1,2,3,_,5
    cat AND dog should return file 1,4 regexp:
    cat OR dog should return file 1,2,3,4 regexp:(cat)|(dog)
    cat NOT dog should return file 3 regexp:
    NOT cat OR dog should return file 5 regexp:

    I tried EVERYTHING that I could find (spent 3 hrs on this) and could not get it to work correctly. At one time I got results but my joy was short lived when I realized that they were wrong.
    Summary: So far this is NOT possible. According to some RegEx dictates that AND is defaulted so that /ab/ is like saying 'a AND b'. So regexp:[(cat)(dog)] should have worked, but I could not get it to work correctly.
    maybe something I could look into but don't get your hopes up.

     
  • jmj

    jmj - 2017-08-24

    Searching content from the file is not very educated and is just a very simple algorithm. It does not support logical operations, but regular expressions should work. I am not so familiar with regular expressions but should "cat|dog" work for OR searchers?

    Regular expressions are handled by the PCRE library.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.