Perl censor

Discussion in 'General Software' started by seamer, Nov 16, 2010.

  1. seamer

    seamer Member

    Joined:
    Aug 19, 2001
    Messages:
    1,825
    Location:
    san jose, california
    Hi guys,

    How would I use perl to block "ass" but not legitimate words like "class", "pass", and "glass"? The various tutes I've seen don't seem to make anything clear. I know it's simple, which drives me nuts. :(

    -B
     
  2. grs1961

    grs1961 Member

    Joined:
    Jan 21, 2005
    Messages:
    524
    Location:
    Melbourne
    What makes you think "ass" is not a legitimate word?

    Catriona, a pretty young lass,
    Had a truly magnificent ass.
    Not rounded and pink,
    As you possibly think,
    It was grey, had long ears, and ate grass.

    IOW - any solution that relies on pattern matching rather than contextual analysis has already failed.
     
  3. chip

    chip Member

    Joined:
    Dec 24, 2001
    Messages:
    3,961
    Location:
    Pooraka Maccas drivethrough
    I hope you don't have the same prejudice against arses as you against donkeys.

    On topic, there's at least 1 module on CPAN that handles regexes for profanity.
     
  4. SLATYE

    SLATYE SLATYE, not SLAYTE

    Joined:
    Nov 11, 2002
    Messages:
    26,857
    Location:
    Canberra
    Why not just look for the relevant word with a space at either end? Then if it's within another word it won't be touched.
     
  5. malloc

    malloc Member

    Joined:
    Dec 15, 2005
    Messages:
    529
    Location:
    Adelaide
  6. OP
    OP
    seamer

    seamer Member

    Joined:
    Aug 19, 2001
    Messages:
    1,825
    Location:
    san jose, california
    "ass" is an awesome string for seeing how regexp works. :)

    The problem is figuring out regexp... And I'm struggling.
     

Share This Page

Advertisement: