def convert(value, row):
    ''' pobx -> pob:
    
    Convert original place of birth string to a standardized place of birth integer value.
    First try to lookup entire string in crosswalk. If a match can not be found on the string
    than apply additional rules to clean original string and attempt to rematch or use other
    coding rules to determine place of birth. If identification fails than add place of birth
    string to a report for review and either manually convert or create new rules.
    '''
    #If pobx is blank then set POB2 to 99
    if not row['pobx']:
        return '99'
    
    v = row['pobx'].strip().lower()
    #TODO see if this maes a difference
    
    try:
        ''' Step 1:
            a. Remove the punctuation from POBX (currently only comma and period)
            b. Remove YY from POBX
            c. Replace zero with O
            d. Check to see if value in crosswalk
            
            Regex explanation: re.sub(' yy|[,.]', '', v)
            1. re.sub(...) http://docs.python.org/library/re.html#re.sub
               re -> accesses the regular expression module
               .sub -> calls the substitution function
            2. (' yy|[,.]', '', v)
               If ' yy' OR [',' OR '.'] is in value replace with empty string
               To add more strings to match on add OR and string
                 example: To replace 'zz' with empty string change above from ' yy|[,.]' to ' yy|zz|[,.]'
               To add more characters to match on place inside brackets
                 example: To replace ';' to empty string change above from ' yy|[,.]' to ' yy|[,.;]'
        '''
        
        v_1 = re.sub(' yy|[,.]', '', v)
        v_1 = v_1.replace('0', 'o')
        
        return crosswalk['default'].convert(v_1).upper()
    except ConvertError:
        ''' Step 2:
            a. If POBX is less than 3 digits it was not in the crosswalk so return 77
            b. If space or comma proceeds the last two digits than check crosswalk for last two digits
            c. If two digits are found but not in crosswalk then return 77
        '''
        l = len(v)
        
        if l < 3:
            return '99'
    
        if v[l-3] in (',', ' '):
            try:
                return crosswalk['default'].convert(v[l-2:l]).upper()
            except ConvertError:
                return '99'
        else:
            try:
                #switch steps three and four to make more efficient (but will make code more complex
                ''' Step 3:
                    a. Check to see if two commas, if match than check crosswalk for that value 
                '''
                if re.search('(?<=,).*(?=,)', v):
                    v = re.search('(?<=,).*(?=,)', v).group()
                    return crosswalk['default'].convert(v.strip()).upper()
                else:
                    ''' Step 4:
                        a. Match all text after a comma and check to see if that value is in crosswalk
                    '''
                    
                    v = re.search('(?<=,).*', v)
                    if v:
                        return crosswalk['default'].convert(v.group().strip()).upper()
            except ConvertError:
                ''' Step 5:
                    a. All lookups in crosswalk failed, POBX = 77 
                '''
                log.write('pob', [row['id'], row['rapstatex'], row['pobx'], "key_1 not in xwalk"])
                return '99'
        
        log.write('pob', [row['id'], row['rapstatex'], row['pobx'], "key_1 not in xwalk."])
        return '99'