Find text except for some with these words

Results 1 to 2 of 2

Thread: Find text except for some with these words

  1. #1
    Join Date
    Dec 1969

    Default Find text except for some with these words

    Hi,<BR><BR>I am working on a thing where I scan a text for illegal words. <BR>Example"<BR>I want to find words in a text with the word "dick" but I want to allow words like dickens, dick tracey, philip dick<BR><BR>I tried the following:<BR><BR>dickW[^(tracey)]<BR><BR>to check if it allowed dick tracey but caught dick<BR>This does not happen...<BR><BR>Any good ideas?<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default Pardon me, but that's silly...

    "dickens" is easy. You just put a non-word bound on either side of the word:<BR> var re = /WdickW/ig<BR><BR>But how in the world is the poor system supposed to be able to find *ALL* possible pairs of words that you *do* want to allow???<BR><BR>You&#039;d have to list each and every one!<BR><BR>But to answer your question:<BR> [...]<BR>means "any *ONE* character of those between the brackets".<BR><BR>And <BR> [^...]<BR>means "any *ONE* character that is *NOT* between the brackets (except the ^)".<BR><BR>so:<BR> /dickW(tracey){0,0}/<BR>maybe???<BR><BR>Says look for "dick" with ZERO occurrences of "tracey" following?<BR><BR>Untested.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts