def _convert(s, re_pattern, syllable_function, add_apostrophes=False,<EOL>remove_apostrophes=False, separate_syllables=False):
original = s<EOL>new = '<STR_LIT>'<EOL>while original:<EOL><INDENT>match = re.search(re_pattern, original, re.IGNORECASE | re.UNICODE)<EOL>if match is None and original:<EOL><INDENT>new += original<EOL>break<EOL><DEDENT>match_start, match_end = match.span()<EOL>if match_start > <NUM_LIT:0>:  <EOL><INDENT>if (new and remove_apostrophes and match_start == <NUM_LIT:1> and<EOL>original[<NUM_LIT:0>] == "<STR_LIT:'>"):<EOL><INDENT>pass  <EOL>if separate_syllables:  <EOL><INDENT>new += '<STR_LIT:U+0020>'<EOL><DEDENT><DEDENT>else:<EOL><INDENT>new += original[<NUM_LIT:0>:match_start]<EOL><DEDENT><DEDENT>else:  <EOL><INDENT>if new and separate_syllables:  <EOL><INDENT>new += '<STR_LIT:U+0020>'<EOL><DEDENT>elif (new and add_apostrophes and<EOL>match.group()[<NUM_LIT:0>].lower() in _UNACCENTED_VOWELS):<EOL><INDENT>new += "<STR_LIT:'>"<EOL><DEDENT><DEDENT>new += syllable_function(match.group())<EOL>original = original[match_end:]<EOL><DEDENT>return new<EOL>
Convert a string's syllables to a different transcription system.