I want to identify strings with more than 3 non-alphanumerics (except \.\- \s) in it, which counts punctuations & special characters.
I've tried with below regex but it identifies strings with "non-alphanumerics in sequence"
([^a-zA-Z0-9.-\s]){2,}
eg: abc__def is identified, ab_c_d is not identified
I want to identify any string which has more than 3 non-alphanumerics (except \.\- \s)
If you want strings to be identified in which at least three (as suggested by your examples) non-alphanumerics occur, not necessarily in sequence, you can use:
([^a-zA-Z0-9.\-\s].*){3}
You can simply use {3} because .* at the end will take care of the remainder of the string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With