Test, validate and match regular expressions
Matches the query string parameter 'foo' in URLs, handling three cases: a key-value pair (foo=value, stopping before & or #), a bare key followed by another parameter delimiter, or a bare key at the end of the string. The lookbehind (?<=[?&]) ensures 'foo' only matches when preceded by a ? or & separator. Useful for extracting, validating, or removing a specific query parameter during URL or query string parsing tasks.