I have this code in Python (where _l is each line of some PHP code I'm iterating through):
_l = re.sub(r'(?:\=\s*|\=\>\s*|\(\s*|\s)(true|false|null)(?:\s*\)|\s*\;|\s*\,)', lambda pattern: pattern.group(1).upper(), _l)
The intention is for it to substitute certain primitives to uppercase, like this (in PHP):
$variable = true; // Old
$variable = TRUE; // New
But instead, I get this:
$variable TRUE
Basically I want to only replace the captured group and ignore the two non-capturing groups. It's probably horrendously obvious but I'm a Python novice :)
Thanks!