Where a regex must be used, there is a reference regex for parsing URL: https://tools.ietf.org/html/rfc3986#appendix-B
Edit: a permalink to demonstrate the above reference regex: https://regex101.com/r/yJ5nU4/1 -- would have prevented the LastPass bug.
The string "foo" correctly gets parsed as a path (group 5). However the string "foo;key:value" gets parsed as a "foo;key" scheme (group 1,2) and a "bar" path (group 5) by the regular expression, but as a path if you follow the grammar.
scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
vs.
^(([^:\/?#]+):)?
:; are reserved characters, but they do not need to be encoded when they are a part of the path.
So yeah, don't use regular expressions for parsing.
Verbal Expressions - It's an extremely good higher level interface to the underlying regular expressions tools, in MANY languages.
Including:
JavaScript - https://github.com/VerbalExpressions/JSVerbalExpressions
ActionScript 3 - https://github.com/VerbalExpressions/AS3VerbalExpressions
Clojure - https://github.com/VerbalExpressions/ClojureVerbalExpression...
C++ - https://github.com/VerbalExpressions/CppVerbalExpressions
C# - https://github.com/VerbalExpressions/CSharpVerbalExpressions
Dart - https://github.com/VerbalExpressions/DartVerbalExpressions
Elixir - https://github.com/VerbalExpressions/ElixirVerbalExpressions
Elm - https://github.com/VerbalExpressions/elm-verbal-expressions
Erlang - https://github.com/VerbalExpressions/ErlangVerbalExpressions
FreeBasic - https://github.com/VerbalExpressions/FreeBasicVerbalExpressi...
F# - https://github.com/VerbalExpressions/FSharpVerbalExpressions
Go - https://github.com/VerbalExpressions/GoVerbalExpressions
Groovy - https://github.com/VerbalExpressions/GroovyVerbalExpressions
Haskell - https://github.com/VerbalExpressions/HaskellVerbalExpression...
Haxe - https://github.com/VerbalExpressions/HaxeVerbalExpressions
Java - https://github.com/VerbalExpressions/JavaVerbalExpressions
Lua - https://github.com/VerbalExpressions/LuaVerbalExpressions
Objective C - https://github.com/VerbalExpressions/ObjectiveCVerbalExpress...
Perl - https://github.com/VerbalExpressions/PerlVerbalExpressions
PHP - https://github.com/VerbalExpressions/PHPVerbalExpressions
PowerShell - https://github.com/VerbalExpressions/PowerShellVerbalExpress...
PureScript - https://github.com/VerbalExpressions/purescript-verbal-expre...
Python - https://github.com/VerbalExpressions/PythonVerbalExpressions
Racket - https://github.com/VerbalExpressions/RacketVerbalExpressions
Ruby - https://github.com/VerbalExpressions/RubyVerbalExpressions
Rust - https://github.com/VerbalExpressions/RustVerbalExpressions
Scala - https://github.com/VerbalExpressions/ScalaVerbalExpressions
Swift - https://github.com/VerbalExpressions/SwiftVerbalExpressions
Vala - https://github.com/VerbalExpressions/ValaVerbalExpressions
And probably more, but that's just the "official" implementations.