Regex to parse URLs for their correctness according to RFC 3986
Holy regex Batman!

Without testing, you should be able to replace all occurrences of:


[0-9] with \d
[A-Za-z0-9] with [\w^_]
[A-Fa-f0-9] with \p{XDigit}
[A-Za-z0-9-._~] with [\w.~-]


and so forth. See documentation for Pattern.

As for your capturing groups I'm quite sure you can do some clever back referencing there but I will save my sanity and not try to parse the regexp. :)