The address can only contain letters, numbers, % and one dash (-) all other special characters are not allowed. The single dash (-) can only be positioned between 2 numbers. The % symbol can be positioned anywhere in the address and there can be multiple occurrences of it.
Valid: 1-10 Downing Street
Valid: Downing Street 1-10
Valid: Downing Street
Valid: Downing%
Valid: %Downing Street
Valid: %Dow%ng Street
Invalid: -10 Downing Street
I am using Java Pattern and Matcher to validate the address. Any help is greatly appreciated.
Try this regex: