I want to see if a given string matches 'test/*', where the asterisk is marking any characters. How can I implement this with Java regular expressions? I tried mystring.matches("test[/].*+"), but it did not work.
test - my String
[/] - 1× forward slash
. - any character
*+ - 0 or more times
What’s wrong here?
You’re using too much syntax. Try:
The
/doesn’t need to be in square brackets (although it would work the same anyway), and*means “repeat the previous thing zero or more times”. Your extra+on the end is likely causing your problem.