3

Windows 10 64-bit. Powershell 5. Notepad++ v.7 32-bit

Regex: Every occurrence of ci not in the words:

associate associates associations capacitor cellspacing cig cipher circle circuit circular circumstances cite citi city commercial crucial dcim decide dependencies electricity especially explicitly fencing forcing gci implicit insecticide insufficient lucida Macie Macintosh official opacity pci pci-e placing policies precision principals reducing replacing social spacing special specification specify specified specifies specifying tracing warcinfo

I need to check / edit the occurrence of the word / string ci in 39 ascii text documents. I can reduce by 99% the items I have to check by not looking for ci in a list of words.

I can delimit the words by: |, comma, tab, space, single line, multi line ....

I've missed the logic of the Google pages I've read.

How would you proceed?

/(ci)/g finds every occurrence of ci

Does not find enough:

\b(?!list|of|words|delimited|by|pipe)\b(ci)

Finds nothing:

^\/(?!list|of|words|delimited|by|pipe)((ci)+)$

Find every occurrence of x in the words y, every occurrence of x in a list of words.

1
  • Please, don't change completly the question. You'd better ask a new one.
    – Toto
    Commented Nov 26, 2019 at 9:06

1 Answer 1

5

Using Notepad++

You have to concat all unwanted words with a pipe as delimiter then insert this string in a negative lookahead just before the string to search (i.e. \w*ci\w*). So the regex is:

\b(?!associate|associates|associations|capacitor|cellspacing|cig|cipher|circle|circuit|circular|circumstances|cite|citi|city|commercial|crucial|dcim|decide|dependencies|electricity|especially|explicitly|fencing|forcing|gci|implicit|insecticide|insufficient|lucida|Macie|Macintosh|official|opacity|pci|pci-e|placing|policies|precision|principals|reducing|replacing|social|spacing|special|specification|specify|specified|specifies|specifying|tracing|warcinfo)\w*ci\w*

I've done a test with your question as text, it found only 3 times the word ci, twice alone and once in the word ascii

Screen capture:

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .