Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6029729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:55:45+00:00 2026-05-23T04:55:45+00:00

Hello All , I am trying to use preg_match to identify if a single

  • 0

Hello All,

I am trying to use preg_match to identify if a single word found within a string of text. This word needs to be picked up if there are multiple instances of each character within the word (in the correct order). To make life hard for myself I also want to pick up on the word even if the client has tried to ‘fool’ the preg_match by means of entering certain characters within the word I wish to match.

It is for use in a swearword filter, if ‘dave’ is found I will replace it with something else. I have tried to come up with the perfect regular expression but I’m not having much luck. Please see the following examples and the issues I have found so far (I have used 3 as an example character the client could use to ‘fool’ the check);


Using: ~\b(?:3+)?d+(?:3+)?a+(?:3+)?v+(?:3+)?e+(?:3+)?\b~i

Okay

  • Input: dave = pass
  • Input: 3d3a3v3e3 = pass
  • Input: ddddaaaavvvveeee = pass
  • Input: 3ave = fail

Not Okay

  • Input: dd3ddaa3aa3vv3vvee3ee = fail (I want this to pass)

Using: ~\b[d3]+[a3]+[v3]+[e3]+\b~i

Okay

  • Input: dave = pass
  • Input: 3d3a3v3e3 = pass
  • Input: ddddaaaavvvveeee = pass
  • Input: dd3ddaa3aa3vv3vvee3ee = pass

Not Okay

  • Input: 3ave = pass (I want this to fail)

Thank you for any help on the regular expression, it’s much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T04:55:46+00:00Added an answer on May 23, 2026 at 4:55 am

    Without discussing if it’s a good profanity filter (probably not!), the following regex will fulfill your spec:

    d.*a.*v.*e
    

    If ‘3’ is the only ‘special’ character, then try this:

    d3*a3*v3*e
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

$('div.box').html(hello) puts the word hello inside all my div's of class 'box'. They all
Hello all you helpful folks @ stackoverflow! Best resources for Java GUI's? Looking at
NOTE: Using .NET 2.0, and VS2005 as IDE Hello all, I'm working on logging
All of my codes fail. They should print he, hello and 5 \n 3,
Hello can anybody solve this please I'm creating the object in the action class
Hullo all, Wondering if there are any Java hackers who can clue me in
Hello I have the following error by git-fsck, which cannot be cleaned by git-gc
Hello again ladies and gents! OK, following on from my other question on ASP.NET
Hello I was writing a Regular Expression (first time in my life I might
Hello I am compiling a program with make but I get the error of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.