javascript - Want to find the Regex pattern for Expression -


i want validate regex pattern given data , correct position of slash in between.

please me regex pattern.

abc/090928/cct001  

i tried following pattern, doesn't correctly validate .

"^[a-za-z^/^0-9^/^a-za-z0-9]*$";

my code:

public class msgidcheck {     public static void main(string args[]) {         string regex = "^[a-za-z]*/[0-9]*/[a-za-z0-9]$*";         string data = "abc/090928/cct001";         system.out.println(data.matches(regex));     } } 

your code not match question ("^[a-za-z]*/[0-9]*/[a-za-z0-9]$*" vs "^[a-za-z^/^0-9^/^a-za-z0-9]*$").

second did not put '$' @ end, need change to

string regex = "^[a-za-z]*/[0-9]*/[a-za-z0-9]*$"; 

Comments