4

I am trying to find if a string fits the format "name"/"version". Here is an example of what I expect to have.

VideoPart/1.2

I've tried many regexes. The closest I have come is this:

"[a-z,A-Z,0-9,\\.]*/[a-z,A-Z,0-9,\\.]"

but it doesn't recognize the format. I am being specific in this regex because I don't want anything more than just one forward-slash. Thanks!

8
  • 2
    Why are you using commas ? Commented Jul 22, 2013 at 16:02
  • 5
    Second part (after /) miss *. Commented Jul 22, 2013 at 16:02
  • I am under the impression that commas are like or's. The text can be any combination of those. Commented Jul 22, 2013 at 16:02
  • 1
    [a-z,A-Z,0-9,\\.] is the same as [a-zA-Z0-9,.]. You don't have to escape periods inside character classes. Commented Jul 22, 2013 at 16:04
  • 1
    @StephenD Elements inside the character class are grouped together already, so [a-zA-Z0-9\.]* is the same thing. Also you may want to use + instead of * otherwise you could match single forward-slashes Commented Jul 22, 2013 at 16:04

1 Answer 1

3

Try this:

\\b[a-zA-Z0-9.]+[/][a-zA-Z0-9.]+\\b

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.