Regex Expression for Specific string in Java -
i new regex expression not able validate string can have number 0-9 fghc,and fghc *#.
i trying [0-9fghcfghc*#]
its working regex tool in java not working.i using java 1.7
e.g.for pattern required 2314f*ghc 12fgh#
etc.
public static void main(string[] args){ string money = "23fghc*#"; pattern p = pattern.compile("[0-9fghcfghc*#]",pattern.case_insensitive); matcher m = p.matcher(money); if (m.matches()) system.out.println("valid:-"+ m); else system.out.println("unvalid:- "+m); }
thank in advance , more explain soultion can have more knowledge in regex
(?i)[0-9fghc*#]+
you need add quantifier @ end well. in case +
match these characters 1 or more times.
use can add (?i)
make case insensitive.
Comments
Post a Comment