Example to check format using regular expression?
Can anyone give me an example of how to check to see if something has a valid format, for example to check if an input has a dollar sign, two digits, a decimal, then two digits? $54.23 would be valid but say 2980 would not be valid.
Specifically, I'm trying to use regular expressions to check if a social security number has the valid format of ###-##-#### # being any digit. Any similar example that is doing this type of check would probably help me understand and allow me to figure it out.
I was just going to put it into a char array and check if the numbers were 0-9 and the -s were -s but they teacher wants us to use a regular expression to do it.
If I understand correctly, I'm going to want a Pattern, Matching, and Boolean but I'm a little confused on how to tell it to match for a pattern of 3 digits - 2 digits - 4 digits.
My java book has a short section on this which shows an example of using .matches to check if a specific word is in a string but that's not really the same as what I am trying to do here. When I try to search online for examples using matches I cant seem to find anything that is checking for a format quite like I'm looking to do. Any help?
Thanks in advance =D