java regex allow optional space character -


i trying create regex pattern match abcdef, abc def, etc.

the patterns tried are:

[a-z]{3}[\s?][a-z]{3} [a-z]{3}[\s*][a-z]{3} [\w]{3}[\s?][\w]{3} \w{3}\s?\w{3} 

all of these seem work abc def, not abcdef.

{edit}

ab cd 12 abc/15 def .*\bab cd\b\s?(\d+)\s?\babc\b[/](\d+)\s?\bdef\b 

i trying extract 12 , 15.

how about:

[\w]{3}\s?[\w]{3} 

or of other combinations. remove \s brackets or put quantifier (i.e. * , ?) outside of bracket space selector:

[\w]{3}[\s]?[\w]{3} 

your bottom 1 should work too.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -