A
A
Alexander Koshelev2021-09-05 21:02:56
Java
Alexander Koshelev, 2021-09-05 21:02:56

How to find a specific number of / in a string in java?

Good afternoon! Please help me create a template for searching for links with two slashes, for example:
site/dir1/
But this type of link is not needed:
site/dir2/example/
Did ". */.*/"
But the links from my first example also come to true and from the second. I tried to simply search by the number / , so that 2 in the line was and not 3 and registered "/ {2}" But it gives an error. Already a lot of things googled but did not find a solution to the nuance.
help me please

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Roo, 2021-09-05
@Xandr24

A dot is any character, incl. and slash.
You need something like [az]+

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question