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

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -