Reputation: 35
I have trouble to translate this php regex /^([-\.\w]+)$/
to java regex.
I try ^([-\\.\\w]+)$
but don't work.
The regex is used to validate a string used for a name of file.
in PHP is not allowed têst.ext
, but in JAVA it's.
Upvotes: 1
Views: 80
Reputation: 425063
In java, it would be:
str.matches("[-.\\w]+")
^
or $
with java's String#matches()
because it's implied (the whole string must match)Upvotes: 2