# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"(\w{3}\s\s\d{1,2} \d{2}:\d{2}:\d{2})\s(\S*)\s(\S*):\s\[(\S*)\]\s\[(\w\d{6})\]\s(\S*)\.(\w*):\s(.*)[\s|\s\[]({.*})"
test_str = ("Feb 5 23:30:09 netoapi-06ae0d2a778f6d96c neto-ecommerce[21749]: [Self=1-5c5a1c7f-1417875ef90160804e31a159;Root=1-5c5a1c78-c849bf9b2a5aa92ee1ffd501] [N015185] app.ERROR: Entity of type 'Neto\\ShopBundle\\Entity\\Country' for IDs code() was not found [] {\"\"tags\"\":[\"\"sales_channels\"\"]}\"\n"
"Feb 5 23:10:00 cpanel-0b75ea0f831a1a35a neto-ecommerce[4987]: [Self=1-5c5a17c8-1b0a7d58cd923b42ff5a7412;Root=1-5c5a17c8-5432af944896f7d093992b3a] [N008907] app.ERROR: Uncaught PHP Exception Symfony\\Component\\HttpKernel\\Exception\\AccessDeniedHttpException: \"\"Installation wizard is not supported for Amazon AU\"\" at /opt/release/Neto6.38.0/vendor/php/symfony/symfony/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php line 117 {\"\"exception\"\":\"\"[object] (Symfony\\\\Component\\\\HttpKernel\\\\Exception\\\\AccessDeniedHttpException(code: 0): Installation wizard is not supported for Amazon AU at /opt/release/Neto6.38.0/vendor/php/symfony/symfony/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php:117, Symfony\\\\Component\\\\Security\\\\Core\\\\Exception\\\\AccessDeniedException(code: 403): Installation wizard is not supported for Amazon AU at /opt/release/Neto6.38.0/vendor/php/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php:379)\"\"} {\"\"tags\"\":[\"\"sales_channels\"\"]}\"\n"
"Feb 5 21:35:06 netoapi-050acc5cb696746e7 neto-ecommerce[31278]: [Self=1-5c5a0188-c0db1f2809ade66c634f9576;Root=1-5c5a0185-b02bf3209835c7a4df7e5c2c] [N015185] app.ERROR: Entity of type 'Neto\\ShopBundle\\Entity\\Country' for IDs code() was not found [] {\"\"tags\"\":[\"\"sales_channels\"\"]}\"\n"
"Feb 6 05:59:30 netoapi-07743f4e14561df22 neto-ecommerce[5407]: [Self=1-5c5a77c1-0019eb7067e6cc30180f9770;Root=1-5c5a77a7-2fa7f778122a1698c2a7e286] [N016687] app.CRITICAL: Uncaught PHP Exception Doctrine\\DBAL\\Exception\\DriverException: \"An exception occured in driver: SQLSTATE[HY000] [1203] User N016687_web already has more than 'max_user_connections' active connections\" at /opt/release/Neto6.38.0/vendor/php/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 115 {\"exception\":\"[object] (Doctrine\\\\DBAL\\\\Exception\\\\DriverException(code: 0): An exception occured in driver: SQLSTATE[HY000] [1203] User N016687_web already has more than 'max_user_connections' active connections at /opt/release/Neto6.38.0/vendor/php/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:115, Doctrine\\\\DBAL\\\\Driver\\\\PDOException(code: 1203): SQLSTATE[HY000] [1203] User N016687_web already has more than 'max_user_connections' active connections at /opt/release/Neto6.38.0/vendor/php/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:47, PDOException(code: 1203): SQLSTATE[HY000] [1203] User N016687_web already has more than 'max_user_connections' active connections at /opt/release/Neto6.38.0/vendor/php/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:43)\"} {\"tags\":[\"sales_channels\"]}")
matches = re.finditer(regex, test_str, re.MULTILINE)
for matchNum, match in enumerate(matches, start=1):
print ("Match {matchNum} was found at {start}-{end}: {match}".format(matchNum = matchNum, start = match.start(), end = match.end(), match = match.group()))
for groupNum in range(0, len(match.groups())):
groupNum = groupNum + 1
print ("Group {groupNum} found at {start}-{end}: {group}".format(groupNum = groupNum, start = match.start(groupNum), end = match.end(groupNum), group = match.group(groupNum)))
# 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