regex detecting "more than one" of entitiy
===

I have strings of the following kind:

    asdf:0123-456-789:USB0::0x1234::0x9ABC::0123-456-789::INSTR

First, there is the name `asdf` followed by the serial `0123-456-789` followed by the address string `USB0::0x1234::0x9ABC::0123-456-789::INSTR`. The format is

    name:serial:addr

**I want to extract the name, the serial and the address into single Strings**. The address can also contain `::` so I can not just `String#split(String regex)` it (or can I?). My idea was to use a regex expression that captures these three entities. I am very new to regex.

I am using Java:

    String input = "asdf:0123-456-789:USB0::0x1234::0x9ABC::0123-456-789::INSTR";
    // name
    Matcher nameMatcher = Pattern.compile("[0-9a-zA-Z]+").matcher(input);
    nameMatcher.find();
    String name = nameMatcher.group();
    // serial
    Matcher serialMatcher = Pattern.compile("[0-9]{3}-[0-9]{9}-[0-9]{4}").matcher(input);
    serialMatcher.find();
    String serial = serialMatcher.group();
    // address
    Matcher addrMatcher = Pattern.compile("[0-9a-zA-Z[:]{2}-]+").matcher(input);
    serialMatcher.find();
    String serial = serialMatcher.group();
    System.out.println(name + " / " + serial + " / " + address);
    
    // result:
    // asdf, 012-012345678-0123, asdf:012-012345678-01234:USB0::0x1234::0x9ABC::012-012345678-01234::INSTR

This works good for name and serial, but not for the address (it captures the whole input string instead of just the address). The problem is that I only want to allow `::` and not `:` but it does not work as I intended. Is there a nice way to match this or is this all way too complicated? If so, can you show me a different approach?