I don't really understand what your issue is.

Your regex matches on:

"something[!stuff]"
"something[!]"
"something"

Isn't that what you want?

Btw I don't really see a purpose, if you make the [!stuff] optional, then you're basically telling the regex it may match any sequence of \w chars = [a-zA-Z0-9_], as long as it's delimited with word boundaries. This is a pretty general match, and will practically match any regular string you throw at it.

Btw is "something[!stuff]" gonna be part of a larger string, or is that the only string etc. etc.
Do you intend to capture anything from the string, or do you solely want to know if the inputted string matches the regex criteria. Will "something" and "stuff" always be sctriclty alpha chars, or can there be others? in case there is "stuff" must it always be preceeded by an exlamation mark? What should the regex do if you input a string that has both "something" as it has "something[!stuff]". What should it do when you pass it "something[.bla]" should try to match the something, or should it discard it alltogether cuz the first letter inside the [ ] was not a ! but a .

You are going to have elaborate on this much more as we are not mind readers.