how to match a number followed immediately by either /tcp or /udp or nothing?
the following illustrates 3 scenario: input --> result
Character class will match any combinations of its included characters. You need to use a logical OR instead.
?: is a non-capture group notation and
? will make your non-capture group optional (for non-suffix cases).
If you want to capture the string if something followed the
/tcp you can use following regex: