How does this sed expression to remove non-alpha characters work?

Hello!

I know that this expression gets rid of non-alphanumeric characters:

sed 's/[^a-zA-z0-9]//g'

and I understand that it is replacing them with nothing - hence the '//'-, but I don't understand how it's doing it.
It seems it's finding strings that begin with alphanumeric and replacing them with nothing! Obviously that would not give the required output so I'm a little confused and clearly missing something...

Thanks for your help!

Could you please post your input code as well your expected output so that we can help you more on same.

Thanks,
R. Singh

The circumflex I marked in red in your code (and please use CODE tags) is not an anchor. When a circumflex is the first character in a matching expression (i.e., [expression specifying a set of characters to match] ), it specifies a non-matching expression where all of the characters except those specified by the expression following the circumflex will be matched. So, in this case everything that is not a lowercase letter, not an uppercase letter, and not a digit is removed (or, as you said, replaced by nothing).