regex - How to match a string with a wildcard character in java -


i need write regular expression match string of value "*.log" have following code , doesnt seem work expected.

if (name.matches("\\*\\.log") 

the above statement returns false, when value of name "*.log"

any appreciated.

why doing that? couldn't do

if(name.endswith(".log")) 

it seems me simpler option, since can before .log, if used wildcard.
also, if want make sure isn't ".log", simple.

if(name.endswith(".log") && !name.equals(".log")) 

hopefully helped bit!


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -