I'm implementing a regular expression to match an absolute URI as defined in
- in the current state there is no capturing of path, query and fragment
- additionaly to the specified
authoritythere are groups capturing
RegEx ~^(?<scheme>.+?):(?://(?<authority>(?:(?<user>.+?)(?::(?<password>.+?))?@)+(?<authlessAuthority>.+)?))?$~ --- Examples https://example.com https://@example.com https://email@example.com https://user:firstname.lastname@example.org
My current problem URI is the second one. This URI is invalid and should not be matched while the
@ character should not be captured within the authority while there is no authentication provided in the URI.
How can I exclude the
@ character from the authority group if there is no authentication provided?