I found the perfect regex for my needs here: [Regex for no duplicate characters from a limited character pool](https://stackoverflow.com/questions/26470820/regex-for-no-duplicate-characters-from-a-limited-character-pool) [Live demo Here](https://regex101.com/r/fN3eR1/2)

But when I test it with bash regex operator it always fails:

```
if [[ 'ABC' =~ ^(?!.*(.).*\1)[ABC]+$ ]]; then
        echo "success"
else
        echo "fail"
fi

```

I also tried it with grep:

```
echo "ABC" | grep -E "^(?!.*(.).*\1)[ABC]+$"

```

But I got *"grep: Invalid back reference"*