Question
Hi there! Below code I am trying to accept only numeric (0-9) and - as input to set my account number; if user enters invalid
Hi there!
Below code I am trying to accept only numeric (0-9) and "-" as input to set my account number; if user enters invalid input, program should throw an exception if it is valid input program should go ahead with the second layer of conditioning (isCheckDigitCorrect() is another method with an algorithm, at this point that method is irrelevant) and if the second condition is also true my program should go ahead and set the account number else throw an exception.
my problem is that, my if statement always returns false, I tried debugging to see if my regex pattern was correct, I found out that if I declare a string, it matches the pattern returning true however if I enter the same input as the declared regex pattern i.e input accountNumber="123-123456" my test variable returns false. What could be the problem here? How can I fix this? Thanks in advance.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started