It would be helpful if you would tell us more precisely what qualifies as valid. It is not possible for others to derive the conditions of validity from your regex when you have already said it does not produce the desired result.
Please tell us more precisely what networks you want to match, with an example of matching and non matching IP.
Please review the
Site FAQ for guidance in posting your questions and general forum usage. Especially, read the link in that page,
How To Ask Questions The Smart Way. The more effort you put into understanding your problem and framing your questions, the better others can help!