A string of letters called a regular expression creates a search pattern. This search pattern may be used to specify your search criteria while looking for information within a text.
Java supports regex matching pattern.
If you use this regex pattern -
^[a-zA-Z_$][a-zA-Z_$0-9]*$
Then you task will be easily done.
A variable name can begin with a-z,A-Z,_ and $ .
A variable name can end with a-z,A-Z,_,$,0-9.
So, by applying above regex, you can enter any String and if that will match then it is a valid variable name otherwise it's not.
Test Case Partition Tested Input(s) Expected output
1 a-z abc Valid
2 A-Z ABC Valid
3 _a-z _abc Valid
4 $0-9 $0 Valid
A regular expression might be a simple pattern or just a single character.
Learn more about String here:
https://brainly.com/question/27832355
#SPJ4