I am looking for a Regular expression to match only numeric strings with special characters and of size 4+. I did a little review on the questions posted in here:
Testing website: http://regexlib.com/RETester.aspx
1- regular expression for numeric and special chacter check
Solution: ^((?!.*?\d)(?!.*?[^\w\s]).)+$
I tried this regular expression on:
- 155-555: No match (wrong)
- 155555: No match (wrong)
2- Regular Expression to match a string of numbers including special characters
Solution: ([-()_.+ ]*\d[-()_.+ ]*){4,}
- 155-555: match (correct)
- 155555: match (correct)
- 155-555aaa: match (wrong)
This regular expressions matched the previous strings. But there is an error. The third string 155-555aaa contains alphabet letters and not special characters. We should have no match for 155-555aaa since a is not a special character. How can I modify this regular expression to only match numeric string with special characters. The numeric string can be of any form:
example: 24332-2432@2342-1234
Special Characters : [&~#"{'[(|-`_\ç^à@)]}=}^¨$$*%ù]
numeric = digits
[^a-zA-Z]{4,}?