This does what you asked for

It does what the OP appears to ask for, but probably in more extreme form than they want - the actual problem they are trying to solve is that "Sometimes when the string is created some bad words are formed and I want to avoid that". So if they test against a list of bad words, this will reject any string sharing even a single character with any of the bad words - potentially rejecting absolutely every string, if the list of bad words is extensive enough.

For this context, one possibility (and one I would guess at) is that the OP wants to match not every length-1 substring of the bad words, but only those substrings that look close enough to the word that they bring it to mind. Assume "LACK" is a bad word: we might think that "LAC" and "LAK" are both close enough to bring it to mind, but that "ACK" is not. In that case a better solution might be to put "LAC" and "LAK" in the naughty list and reject only complete matches.

At this stage, the OP is best served by helping them find the right questions to ask to clarify their own thoughts about what they want to achieve.


In reply to Re^2: Finding a partial match by hv
in thread Finding a partial match by jpys

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.