I wrote this code in JAVA but I don't want to change it from regex to use a loop. Not sure if I should use charAt or not. Kindly help with what the code will look like if it is not regex: protected boolean isTextValueValid(String value){ String regex = "\\b\\d\\{3, 8}"; Pattern p = Pattern.compile(regex); if(value==null || !value.matches(regex)){ return false } Matcher m = p.matcher(value); return m.matches(); } I would appreciate like two options that will use either enhanced Loop or ForLoop
I wrote this code in JAVA but I don't want to change it from regex to use a loop. Not sure if I should use charAt or not.
Kindly help with what the code will look like if it is not regex:
protected boolean isTextValueValid(String value){
String regex = "\\b\\d\\{3, 8}";
Pattern p = Pattern.compile(regex);
if(value==null || !value.matches(regex)){
return false
}
Matcher m = p.matcher(value);
return m.matches();
}
I would appreciate like two options that will use either enhanced Loop or ForLoop
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
Thank you. One more thing in the 2nd option using ENhanced Loop, what if the value has spaces? I know special characters is taken care of but not spaces
This is very helpful. Can you help with how to connect this with using Matcher library