# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"(?<=\'\),')(.*)(?=\',)"
test_str = ("DECODE(TRUE,\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'410'),'Brokered',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'411'),'CDS Listing Service',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'408'),'Long Term - 1 Year or More',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'412'),'Long Term - 1 Year or More',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'418'),'Long Term - 1 Year or More',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'424'),'Long Term - 1 Year or More',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'436'),'Long Term - 1 Year or More',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'448'),'Long Term - 1 Year or More',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'460'),'Long Term - 1 Year or More',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'472'),'Long Term - 1 Year or More',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'484'),'Long Term - 1 Year or More',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'496'),'Long Term - 1 Year or More',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'497'),'Long Term - 1 Year or More',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'708'),'Long Term - 1 Year or More',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'712'),'Long Term - 1 Year or More',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'718'),'Long Term - 1 Year or More',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'724'),'Long Term - 1 Year or More',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'736'),'Long Term - 1 Year or More',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'748'),'Long Term - 1 Year or More',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'760'),'Long Term - 1 Year or More',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'772'),'Long Term - 1 Year or More',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'784'),'Long Term - 1 Year or More',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'796'),'Long Term - 1 Year or More',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'797'),'Long Term - 1 Year or More',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'400'),'Public Funds CD',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'700'),'Public Funds CD',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'407'),'Short Term - Less than 1 Year',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'432'),'Short Term - Less than 1 Year',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'482'),'Short Term - Less than 1 Year',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'491'),'Short Term - Less than 1 Year',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'707'),'Short Term - Less than 1 Year',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'732'),'Short Term - Less than 1 Year',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'782'),'Short Term - Less than 1 Year',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'791'),'Short Term - Less than 1 Year',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'100'),'Checking',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'101'),'Checking',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'102'),'Checking',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'110'),'Checking',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'111'),'Checking',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'115'),'Checking',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'125'),'Checking',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'127'),'Checking',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'130'),'Checking',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'149'),'Checking',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'150'),'Checking',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'151'),'Checking',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'314'),'Checking',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'320'),'Checking',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'345'),'Checking',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'380'),'Checking',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'381'),'Checking',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'382'),'Checking',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'386'),'Checking',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'387'),'Checking',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'330'),'HSA',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'331'),'HSA',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'161'),'Money Management',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'351'),'Money Management',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'375'),'Portfolio Investment',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'376'),'Portfolio Investment',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'377'),'Portfolio Investment',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'385'),'Portfolio Investment',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'303'),'Sweep LOC',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'841'),'Sweep LOC',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'842'),'Sweep LOC',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'843'),'Sweep LOC',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'508'),'Long Term - 1 Year or More',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'510'),'Long Term - 1 Year or More',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'512'),'Long Term - 1 Year or More',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'518'),'Long Term - 1 Year or More',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'524'),'Long Term - 1 Year or More',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'536'),'Long Term - 1 Year or More',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'540'),'Long Term - 1 Year or More',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'548'),'Long Term - 1 Year or More',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'560'),'Long Term - 1 Year or More',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'572'),'Long Term - 1 Year or More',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'584'),'Long Term - 1 Year or More',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'596'),'Long Term - 1 Year or More',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'597'),'Long Term - 1 Year or More',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'599'),'Savings',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'503'),'Short Term - Less than 1 Year',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'507'),'Short Term - Less than 1 Year',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'532'),'Short Term - Less than 1 Year',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'582'),'Short Term - Less than 1 Year',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'851'),'Holiday',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'820'),'Savings',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'825'),'Savings',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'830'),'Savings',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'845'),'Savings',\n"
"IN(LTRIM(RTRIM(deposit_account_type__)),'887'),'Savings'\n"
")")
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