# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"((?<=\"pressure\"..\"pressure\")[^\"]+(?=\")\"*[a-zA-Z]+\"[,]\s+)(\d)[.](\d)(\d+)(,[^\d])(([-]\d+).(\d)(\d+)),[^\d]"
test_str = ("\"0x03\": [ \n"
" [\"Q1000 LPG\", \"P94_0_00\", 0, 0, \"0x30\",\"0x03\", 0, \"pressure\" ,\"pressure\", [], 0.0,0.0, 0.1, \"False\", 1.5618, 0.0, 0.0, 5.0, \"[10.0, None]\", \"Lps\"],\n"
" [\"P1000 LPG Tank\", \"P94_0_01\", 0, 1, \"0x30\",\"0x03\", 0, \"pressure\", \"pressure\", [], 0.0,0.0, 0.1, \"True\", 1.5633, -1.1520, 0.0, 5.0, \"[10.0, 'None']\", \"MPa\"],\n"
" [\"P1004 LPG Injector\", \"P94_0_02\", 0, 2, \"0x30\",\"0x03\", 0, \"pressure\" ,\"pressure\", [], 0.0,0.0, 0.1, \"True\", 3.1146, -2.3736, 0.0, 10.0, \"[10.0, 'None']\", \"MPa\"],\n"
" [\"P1006 Chamber\", \"P94_0_03\", 0, 3, \"0x30\",\"0x03\", 0, \"pressure\" ,\"pressure\", [], 0.0,0.0, 0.1, \"True\", 3.1317, -2.3863, 0.0, 10.0, \"[10.0, 'None']\", \"MPa\"],\n"
" [\"P1002 GOX Inlet\", \"P94_0_04\", 0, 4, \"0x30\",\"0x03\", 0, \"pressure\" ,\"pressure\", [], 0.0,0.0, 0.1, \"True\", 3.1276, -2.3934, 0.0, 10.0, \"[10.0, 'None']\", \"MPa\"],\n"
" [\"P1001 GOX Supply\", \"P94_0_05\", 0, 5, \"0x30\",\"0x03\", 0, \"pressure\" ,\"pressure\", [], 0.0,0.0, 0.1, \"True\", 1.5622, -1.1519, 0.0, 5.0, \"[10.0, None]\", \"MPa\"],\n"
" [\"P 06\", \"P94_0_06\", 0, 6, \"0x30\",\"0x03\", 0, \"pressure\" ,\"pressure\", [], 0.0,0.0, 0, \"False\", 1.5629, -1.1533, 0.0, 5.0, \"[10.0, None]\", \"MPa\"],\n"
" [\"P 07\", \"P94_0_07\", 0, 7, \"0x30\",\"0x03\", 0, \"pressure\" ,\"pressure\", [], 0.0,0.0, 0, \"False\", 1.5633, -1.1548, 0.0, 5.0, \"[10.0, None]\", \"MPa\"],\n"
" [\"P 08\", \"P94_0_08\", 0, 8, \"0x30\",\"0x03\", 0, \"pressure\" ,\"pressure\", [], 0.0,0.0, 0, \"False\", 1.5622, -1.1556, 0.0, 5.0, \"[10.0, None]\", \"MPa\"],\n"
" [\"P 09\", \"P94_0_09\", 0, 9, \"0x30\",\"0x03\", 0, \"pressure\" ,\"pressure\", [], 0.0,0.0, 0, \"False\", 1.5605, -1.142, 0.0, 5.0, \"[10.0, None]\", \"MPa\"],\n"
" [\"P 10\", \"P94_0_10\", 0, 10, \"0x30\",\"0x03\", 0,\"pressure\" ,\"pressure\", [], 0.0,0.0, 0, \"False\", 3.1326, -2.4067, 0.0, 5.0, \"[10.0, None]\", \"MPa\"],\n"
" [\"P 11\", \"P94_0_11\", 0, 11, \"0x30\",\"0x03\", 0,\"pressure\" ,\"pressure\", [], 0.0,0.0, 0, \"False\", 3.1354, -2.4408, 0.0, 5.0, \"[10.0, None]\", \"MPa\"],\n"
" [\"P 12\", \"P94_0_12\", 0, 12, \"0x30\",\"0x03\", 0,\"pressure\" ,\"pressure\", [], 0.0,0.0, 0, \"False\", 3.1354, -2.4408, 0.0, 5.0, \"[10.0, None]\", \"MPa\"],\n"
" [\"P 13\", \"P94_0_13\", 0, 13, \"0x30\",\"0x03\", 0,\"pressure\" ,\"pressure\", [], 0.0,0.0, 0, \"False\", 3.1354, -2.4408, 0.0, 5.0, \"[10.0, None]\", \"MPa\"],\n"
" \n"
" [\"T 00\", \"M94_1_00\", 1, 0, \"0x30\",\"0x03\", 1, \"temperature\" ,\"tempTypePT100_TypeA\", [\"M94_2_00\"], 1.0,0.0, 0.2, \"False\", 1.0, 0.0, 0.0, 373.15, \"[10.0, None]\", \"K\"],\n"
" [\"T 01\", \"M94_1_01\", 1, 1, \"0x30\",\"0x03\", 1, \"temperature\" ,\"tempTypePT100_TypeA\", [\"M94_2_01\"], 1.0,0.0, 0.2, \"False\", 1.0, 0.0, 0.0, 373.15, \"[10.0, None]\", \"K\"],\n"
" [\"T 02\", \"M94_1_02\", 1, 2, \"0x30\",\"0x03\", 1, \"temperature\" ,\"tempTypePT100_TypeA\", [\"M94_2_02\"], 1.0,0.0, 0.2, \"False\", 1.0, 0.0, 0.0, 373.15, \"[10.0, None]\", \"K\"],\n"
" [\"T 03\", \"M94_1_03\", 1, 3, \"0x30\",\"0x03\", 1, \"temperature\" ,\"tempTypePT100_TypeA\", [\"M94_2_03\"], 1.0,0.0, 0.2, \"False\", 1.0, 0.0, 0.0, 373.15, \"[10.0, None]\", \"K\"],\n"
" [\"T 04\", \"M94_1_04\", 1, 4, \"0x30\",\"0x03\", 1, \"temperature\" ,\"tempTypePT100_TypeA\", [\"M94_2_04\"], 1.0,0.0, 0.2, \"False\", 1.0, 0.0, 0.0, 373.15, \"[10.0, None]\", \"K\"],\n"
" [\"T 05\", \"M94_1_05\", 1, 5, \"0x30\",\"0x03\", 1, \"temperature\" ,\"tempTypePT100_TypeA\", [\"M94_2_05\"], 1.0,0.0, 0.2, \"False\", 1.0, 0.0, 0.0, 373.15, \"[10.0, None]\", \"K\"],\n"
" [\"T 06\", \"M94_1_06\", 1, 6, \"0x30\",\"0x03\", 1, \"temperature\" ,\"tempTypePT100_TypeA\", [\"M94_2_06\"], 1.0,0.0, 0.2, \"False\", 1.0, 0.0, 0.0, 373.15, \"[10.0, None]\", \"K\"],\n"
" [\"T 07\", \"M94_1_07\", 1, 7, \"0x30\",\"0x03\", 1, \"temperature\" ,\"tempTypePT100_TypeA\", [\"M94_2_07\"], 1.0,0.0, 0.2, \"False\", 1.0, 0.0, 0.0, 373.15, \"[10.0, None]\", \"K\"],\n"
" [\"T 08\", \"M94_1_08\", 1, 8, \"0x30\",\"0x03\", 1, \"temperature\" ,\"tempTypePT100_TypeA\", [\"M94_2_08\"], 1.0,0.0, 0.2, \"False\", 1.0, 0.0, 0.0, 373.15, \"[10.0, None]\", \"K\"],\n"
" [\"T 09\", \"M94_1_09\", 1, 9, \"0x30\",\"0x03\", 1, \"temperature\" ,\"tempTypePT100_TypeA\", [\"M94_2_09\"], 1.0,0.0, 0.2, \"False\", 1.0, 0.0, 0.0, 373.15, \"[10.0, None]\", \"K\"],\n"
" [\"T 10\", \"M94_1_10\", 1, 10, \"0x30\",\"0x03\", 1, \"temperature\" ,\"tempTypePT100_TypeA\", [\"M94_2_10\"], 1.0,0.0, 0.2, \"False\", 1.0, 0.0, 0.0, 373.15, \"[10.0, None]\", \"K\"],\n"
" [\"T 11\", \"M94_1_11\", 1, 11, \"0x30\",\"0x03\", 1, \"temperature\" ,\"tempTypePT100_TypeA\", [\"M94_2_11\"], 1.0,0.0, 0.2, \"False\", 1.0, 0.0, 0.0, 373.15, \"[10.0, None]\", \"K\"],\n"
" [\"T 12\", \"M94_1_12\", 1, 12, \"0x30\",\"0x03\", 1, \"temperature\" ,\"tempTypePT100_TypeA\", [\"M94_2_12\"], 1.0,0.0, 0.2, \"False\", 1.0, 0.0, 0.0, 373.15, \"[10.0, None]\", \"K\"],\n"
" [\"T 13\", \"M94_1_13\", 1, 13, \"0x30\",\"0x03\", 1, \"temperature\" ,\"tempTypePT100_TypeA\", [\"M94_2_13\"], 1.0,0.0, 0.2, \"False\", 1.0, 0.0, 0.0, 373.15, \"[10.0, None]\", \"K\"],\n"
" [\"T 14\", \"M94_1_14\", 1, 14, \"0x30\",\"0x03\", 1, \"temperature\" ,\"tempTypePT100_TypeA\", [\"M94_2_14\"], 1.0,0.0, 0.2, \"False\", 1.0, 0.0, 0.0, 373.15, \"[10.0, None]\", \"K\"],\n"
" [\"T 15\", \"M94_1_15\", 1, 15, \"0x30\",\"0x03\", 1, \"temperature\" ,\"tempTypePT100_TypeA\", [\"M94_2_15\"], 1.0,0.0, 0, \"False\", 1.0, 0.0, 0.0, 373.15, \"[10.0, None]\", \"K\"],\n"
" \n"
" [\"T 00 Comp\",\"M94_2_00\", 2, 0, \"0x30\",\"0x03\", 1, \"volt\" ,\"volt\", [], 1.0,0.0, 0, \"False\", 1.0, 0.0, 0.0, 5.0, \"[10.0, None]\", \"V\"],\n"
" [\"T 01 Comp\",\"M94_2_01\", 2, 1, \"0x30\",\"0x03\", 1, \"volt\" ,\"volt\", [], 1.0,0.0, 0, \"False\", 1.0, 0.0, 0.0, 5.0, \"[10.0, None]\", \"V\"],\n"
" [\"T 02 Comp\",\"M94_2_02\", 2, 2, \"0x30\",\"0x03\", 1, \"volt\" ,\"volt\", [], 1.0,0.0, 0, \"False\", 1.0, 0.0, 0.0, 5.0, \"[10.0, None]\", \"V\"],\n"
" [\"T 03 Comp\",\"M94_2_03\", 2, 3, \"0x30\",\"0x03\", 1, \"volt\" ,\"volt\", [], 1.0,0.0, 0, \"False\", 1.0, 0.0, 0.0, 5.0, \"[10.0, None]\", \"V\"],\n"
" [\"T 04 Comp\",\"M94_2_04\", 2, 4, \"0x30\",\"0x03\", 1, \"volt\" ,\"volt\", [], 1.0,0.0, 0, \"False\", 1.0, 0.0, 0.0, 5.0, \"[10.0, None]\", \"V\"],\n"
" [\"T 05 Comp\",\"M94_2_05\", 2, 5, \"0x30\",\"0x03\", 1, \"volt\" ,\"volt\", [], 1.0,0.0, 0, \"False\", 1.0, 0.0, 0.0, 5.0, \"[10.0, None]\", \"V\"],\n"
" [\"T 06 Comp\",\"M94_2_06\", 2, 6, \"0x30\",\"0x03\", 1, \"volt\" ,\"volt\", [], 1.0,0.0, 0, \"False\", 1.0, 0.0, 0.0, 5.0, \"[10.0, None]\", \"V\"],\n"
" [\"T 07 Comp\",\"M94_2_07\", 2, 7, \"0x30\",\"0x03\", 1, \"volt\" ,\"volt\", [], 1.0,0.0, 0, \"False\", 1.0, 0.0, 0.0, 5.0, \"[10.0, None]\", \"V\"],\n"
" [\"T 08 Comp\",\"M94_2_08\", 2, 8, \"0x30\",\"0x03\", 1, \"volt\" ,\"volt\", [], 1.0,0.0, 0, \"False\", 1.0, 0.0, 0.0, 5.0, \"[10.0, None]\", \"V\"],\n"
" [\"T 09 Comp\",\"M94_2_09\", 2, 9, \"0x30\",\"0x03\", 1, \"volt\" ,\"volt\", [], 1.0,0.0, 0, \"False\", 1.0, 0.0, 0.0, 5.0, \"[10.0, None]\", \"V\"],")
subst = "\\1\\2\\3.\\4\\5\\7\\8.\\9"
# You can manually specify the number of replacements by changing the 4th argument
result = re.sub(regex, subst, test_str, 0, re.MULTILINE)
if result:
print (result)
# Note: for Python 2.7 compatibility, use ur"" to prefix the regex and u"" to prefix the test string and substitution.
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 Python, please visit: https://docs.python.org/3/library/re.html