I am to write a regex for following requirements
You can solve these with a combination of lookaheads:
(?=.*[a-zA-Z])(?=.*\d).{8}(?=.*[^\da-zA-Z])The last one just requires a non-letter and non-digit which is probably by far the easiest way of specifying that you want a somewhat “special” character.
So in the end you have
^(?=.*[a-zA-Z])(?=.*\d)(?=.*[^\da-zA-Z]).{8}$