Hi,
I am validating a phone number field and require the data in the field to start with + and contain numeric or whitespace characters.
Below is my code I am using to validate.
The value of b is always false.
Can you please let know the correct regular expression to use so that it returns true for a phone number with spaces ?
import java.util.regex.Pattern;
public class Hello {
public static void main(String[] args) {
String userContent = ("+0123 456 789");
boolean b = Pattern.matches("^\\+{1}?[0-9]\\s$", userContent);
System.out.println("userContent :"+ userContent);
System.out.println("b :"+ b);
}
}
Thanks