Test, validate and match regular expressions
Matches key-value pairs in object literal or similar syntax by capturing a key of word characters (letters, digits, underscores) followed by a colon, an optional space, and a value of letters, digits, or quote characters. With global and multiline flags, it finds all such pairs across lines, commonly used with replacement like '$2: $1' to swap keys and values in JavaScript objects or parse simple key-value data.