How to search for words that do **not contain** the character: '



  • How to search for words that do not contain the character: ’
    e.g. white, black?

    accord’s
    black
    D’Arcy
    I’ll
    white



  • @Thomas-Olivier

    Assuming a straight single quote ' instead of a curly one, here is a way to get what you want:

    Mark: \b(?<!')\w+(?!')\b
    

    Put the caret at the very beginning of the document, select just the Regular Expression mode and click on Mark All.

    Hope this helps.



  • Hello, @thomas-olivier, @astrosofista and All,

    @astrosofista, my understanding is slightly different :

    • To get entire line, containing words characters only, use the regex ^\w+$

    • To get entire line, not containing the ' nor the characters, use the regex ^[^'’\r\n]+$

    Test these two regexes against the text below :

    accord’s
    "Program"
    black
    D’Arcy
    and/or
    I’ll
    royalty_free
    machine-readable
    white
    **** NOTEPAD++ LICENSE TERMS ****
    Test
    

    Best Regards,

    guy038



  • Thank you, all 3 work.



  • @guy038, All:

    I usually try to understand OP’s messages as literally as possible, unless it is very obvious that there is some mistake, such as the single quotation mark. In this case I read words and thought they were single words, unconnected to each other, but not necessarily on separate lines. Hence the regular expression I posted.

    Nor did it cross my mind that there could be hyphenated compound words, since the posted sample did not include them.

    However, the scenario that you propose is entirely possible and in fact your two regular expressions are simpler than mine. If I were OP, I would choose one of them.

    Have a nice weekend


Log in to reply