Question: I want to find out if user has used the words `admin` or `username` anywhere in their possible username string.

So if user wants to use `admin`, or `I am admin`, or `my admin name` or `my username`, as their username, I want my regexp to detect it. If he uses `adminmember` I can live with that, don't detect it. I also want detection to be case insensitive.

So far I got this, but it is not really working as I thought, since it will detect words that it shouldn't:

`/^[admin|username]+$/i`

This will match even `adm`, and it shouldn't. I have tried with word boundaries, but I couldn't make it work either, maybe I did something wrong. As you can see in my question I would like to detect word admin anywhere in the string, but if it is a part of some word I can skip it.

Thanks in advance.

Answer: 
Just look for words using word boundaries:

```
/\b(?:admin|username)\b/i

```

and if there is a match return error e.g.

```
if (preg_match('/\b(?:admin|username)\b/i', $input)) {
    die("Invalid Input");
}

```
This might be the pattern that you're looking for:

```
'#(^|\s){1}('. $needle .')($|\s|,|\.){1}#i'

```

Some details depend on the restrictions that you want to apply.