`$` doesn't work like that. Here you're just matching against a literal `$`. In this case, you don't need to add `[&#$]` because the `*` is greedy and it will just match as much as it can. If you ever do need to do something like this, it would have to be `(?:[&#]|$)`