java - How to create regex pattern for validating editext in android? -


am create reg-ex validating edit text field.am not able validate correctly.

my condition validate  example (h2/g2) at-least have 1 numerical value slash allowed one,after "/" must have 1 numerical value. alphabets allowed 

how create reg-ex condition.can 1 know please me solve problem

seems want this: (\w*/)?\w*\d\w*

remember in java have duplicate backslashes \\.

adding more examples of valid , invalid texts help.

edit:

answering comment. yes, does:

string value = "h2/g2"; pattern p = pattern.compile("(\\w*/)?\\w*\\d\\w*"); matcher m = p.matcher(value); log.i("tag", "matches? " + m.matches()); 

prints:

i/tag(12642): matches? true 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -