Good evening (:
When looking at the grammar of URIs in Uri.java you can have userinfo as an empty string and still have the @… so “https://@” should be a valid URI and therefore getUserInfo() should return “”?
Regarding RegEx: The project presentation is also helpful for an introduction to regular expressions in Java.
In RegEx there is a shorthand notation ? for one optional occurrence (compared to the counting notation zero or one occurrence that is not always supported): (regex)?
Do, does this mean it will return an empty String? But isn’t userinfo separated from the "@" symbol? So, in my understanding and looking at this simplification, it should return null, since no user info is passed, only the @-symbol.
Note that an empty string and null (i.e. the absence of a non-terminal) are not the same thing.
URIs always contain scheme, host and path. There are URIs you can deduce from the grammar without ever using the rule for userinfo, for example a://b. Thus getUserInfo should return null. For the URI a://@b, you need to expand the userinfo non-termial to an empty string, thus getUserInfo should return an empty string.