#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?mx)# Keys are pretty much "any text before the '=' symbol"" & @CRLF & _
                "(?P<key>[^=]+)" & @CRLF & _
                "" & @CRLF & _
                "# Match the '=' symbol" & @CRLF & _
                "=" & @CRLF & _
                "" & @CRLF & _
                "(?P<value>" & @CRLF & _
                "  # Lazy match" & @CRLF & _
                "  .*?" & @CRLF & _
                "" & @CRLF & _
                "  # Look-ahead (don't move the "regex cursor", just "peek forward")" & @CRLF & _
                "  (?=" & @CRLF & _
                "    # Match a '_' that has no other '_' between it and the '=' character, or..." & @CRLF & _
                "    _[^_=\n]+=" & @CRLF & _
                "  |" & @CRLF & _
                "    # ... or the end of the line" & @CRLF & _
                "    $" & @CRLF & _
                "  )" & @CRLF & _
                ")" & @CRLF & _
                "" & @CRLF & _
                "# Actually "consume" the '_' character if it exists (or just match the end-of-line)" & @CRLF & _
                "(?:_|$)"
Local $sString = "str=string_number=12345_device=phone_color=blue" & @CRLF & _
                "color=aqua_marine_name=matt_number=123_456_879_lastname=blahblah"
Local $sSubst = "\1 = \2\n"
Local $sResult = StringRegExpReplace($sString, $sRegex, $sSubst)
MsgBox($MB_SYSTEMMODAL, "Result", $sResult)
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for AutoIt, please visit: https://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm