# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"{\"vault\":\"{\"data\":\"(.*)\",\"iv\":\"(.+)\",\"salt\":\"(.+)\"}\"}"
test_str = "{\"vault\":\"{\"data\":\"T0U8fp1y3siwwpTK+tsuoC3s/DfClS3l5RGa9XLbRW3fGFv5xLy2t9knSQrwXEvwEqV36RPIto1Nyn2br3QDtvyE4iKzXGjGk8R0m3SsHFekIR3FUoW4roN3dfkDFyYz/udTwUNVTaQYusUvI05HOrl5x5Q68WM+6wZbR74WlvpK84e2NeELRBvkZX6+hMAEpzguZfk3kds7/1e96yQuYnQc4j/4CYUKKTgUzDrs2Hnvz2iTvgiHrZu8IDc=\",\"iv\":\"n7wMnxUezwXxGmUSVwOKtg==\",\"salt\":\"E9tWReSeZnLzfOsawQ6XA4L3USy8/2OWOmbi6o/yU9c=\"}\"},\"NetworkController\":{\"network\":\"0x1\",\"networkMetadata\":{\"baseFeePerGas\":\"0x10fc587c58\",\"capabilities\":{\"EIP1559\":true}},\"provider\":{\"ticker\":\"ETH\",\"type\":\"mainnet\"}},\"PreferencesController\":{\"accountTokens\":{\"0x8b714e2cb3c9808bb44fd154edfbeed3c9692fd5\":{\"goerli\":[{\"address\":\"0x0d8775f648430679a709e98d2b0cb6250d2887ef\",\"decimals\":18,\"symbol\":\"BAT\"}],\"kovan\":[{\"address\":\"0x0d8775f648430679a709e98d2b0cb6250d2887ef\",\"decimals\":18,\"symbol\":\"BAT\"}],\"mainnet\":[{\"address\":\"0x0d8775f648430679a709e98d2b0cb6250d2887ef\",\"decimals\":18,\"symbol\":\"BAT\"}],\"rinkeby\":[{\"address\":\"0x0d8775f648430679a709e98d2b0cb6250d2887ef\",\"decimals\":18,\"symbol\":\"BAT\"}],\"ropsten\":[{\"address\":\"0x0d8775f648430679a709e98d2b0cb6250d2887ef\",\"decimals\":18,\"symbol\":\"BAT\"}]}},\"assetImages\":{\"0x0d8775f648430679a709e98d2b0cb6250d2887ef\":null},\"batTokenAdded\":{\"0x8b714e2cb3c9808bb44fd154edfbeed3c9692fd5\":true},\"completedOnboarding\":false,\"currentLocale\":\"en\",\"featureFlags\":{\"showIncomingTransactions\":true,\"transactionTime\":false},\"firstTimeFlowType\":null,\"forgottenPassword\":false,\"frequentRpcListDetail\":[],\"hardwareConnect\":false,\"hasNativeIPFSSupport\":false,\"identities\":{\"0x8b714e2cb3c9808bb44fd154edfbeed3c9692fd5\":{\"address\":\"0x8b714e2cb3c9808bb44fd154edfbeed3c9692fd5\",\"lastSelected\":1.634532760173e+12,\"name\":\"Account 1\"}},\"ipfsGateway\":\"dweb.link\",\"knownMethodData\":{},\"lostIdentities\":{},\"metaMetricsId\":null,\"metaMetricsSendCount\":0,\"participateInMetaMetrics\":null,\"preferences\":{\"shouldShowIPFSSection\":false,\"showFiatInTestnets\":false,\"useNativeCurrencyAsPrimaryCurrency\":true},\"selectedAddress\":\"0x8b714e2cb3c9808bb44fd154edfbeed3c9692fd5\",\"suggestedTokens\":{},\"tokens\":[{\"address\":\"0x0d8775f648430679a709e98d2b0cb6250d2887ef\",\"decimals\":18,\"symbol\":\"BAT\"}],\"useBlockie\":false,\"useNonceField\":false,\"usePhishDetect\":true},\"config\":{},\"firstTimeInfo\":{\"date\":1.634532743225e+12,\"version\":\"0.0.0\"}}wdata{\"AlertController\":{\"alertEnabledness\":{\"invalidCustomNetwork\":true,\"unconnectedAccount\":true},\"unconnectedAccountAlertShownOrigins\":{}},\"CachedBalancesController\":{\"cachedBalances\":{\"0x1\":{\"0x8b714e2cb3c9808bb44fd154edfbeed3c9692fd5\":\"0x0\"}}},\"CurrencyController\":{\"conversionDate\":1634532744.578,\"conversionRate\":3858.07,\"currentCurrency\":\"usd\",\"nativeCurrency\":\"ETH\",\"usdConversionRate\":0},\"IncomingTransactionsController\":{\"incomingTransactions\":{},\"incomingTxLastFetchedBlocksByNetwork\":{\"goerli\":null,\"kovan\":null,\"mainnet\":13439794,\"rinkeby\":null,\"ropsten\":null}},\"KeyringController\":{\"vault\":\"{\"data\":\"T0U8fp1y3siwwpTK+tsuoC3s/DfClS3l5RGa9XLbRW3fGFv5xLy2t9knSQrwXEvwEqV36RPIto1Nyn2br3QDtvyE4iKzXGjGk8R0m3SsHFekIR3FUoW4roN3dfkDFyYz/udTwUNVTaQYusUvI05HOrl5x5Q68WM+6wZbR74WlvpK84e2NeELRBvkZX6+hMAEpzguZfk3kds7/1e96yQuYnQc4j/4CYUKKTgUzDrs2Hnvz2iTvgiHrZu8IDc=\",\"iv\":\"n7wMnxUezwXxGmUSVwOKtg==\",\"salt\":\"E9tWReSeZnLzfOsawQ6XA4L3USy8/2OWOmbi6o/yU9c=\"}\"},\"NetworkController\":{\"network\":\"0x1\",\"networkMetadata\":{\"baseFeePerGas\":\"0x10fc587c58\",\"capabilities\":{\"EIP1559\":true}},\"provider\":{\"ticker\":\"ETH\",\"type\":\"mainnet\"}},\"On"
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