Find-AND / Find-OR

Home Forums General General Chat Find-AND / Find-OR

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #25214
    JKluv7
    Participant

    I am wanting to do a search for a line which contains the character strings “AAA” *AND* “BBB”.
    I am wanting to do a search for a line which contains the character strings “AAA” *OR* “BBB”.
    I am not a good CMAC author at all. Are these searches something that MEW can already do, or does someone have a macro already which does these?
    Thanking you all in advance for the assistance.

    #25219
    cwb3106
    Participant

    If all you want to do is a search, you don’t need a macro. Regular Expressions will do what you want. To enable a regular expression search, click on that radio button in the Type option of the Find dialog.

    OR searching is a little easier: To search for AAA or BBB, enter:
    (AAA)|(BBB)
    In the Search for box. In regular expressions, the pipe character means OR and the parenthesis group the characters into strings. Most of the time you don’t need the parentheses and you can simplify the search string to:
    AAA|BBB

    AND searching is a little more complicated because order matters. To search for AAA and BBB IN THAT ORDER, search for:
    AAA.*BBB
    This uses the regular expression idiom “.*” which means any character (“.”) repeated 0 or more times (“*”).

    To search for AAA and BBB in EITHER order, search for:
    (AAA.*BBB)|(BBB.*AAA)
    You may notice that this uses the OR construct described earlier (AAA followed by BBB OR BBB followed by AAA). While the parentheses aren’t necessary, I use them to make the expression easier to read.

    #25220
    JKluv7
    Participant

    Thank you, @cwb3106. While I do not know regular expressions, this give me a good reason to begin learning them. Both the FIND-AND and the FIND-OR works just swell as you outlined them.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.