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
Post a Comment