Take this text for example 泣(な)き出(だ)した, I want to remove the furigana programmatically (ie. 泣き出した). I tried
re.sub(r"\([^()]*\)", "", '泣(な)き出(だ)した')
but it returns 泣した instead. What is the better regular expression?
Take this text for example 泣(な)き出(だ)した, I want to remove the furigana programmatically (ie. 泣き出した). I tried
re.sub(r"\([^()]*\)", "", '泣(な)き出(だ)した')
but it returns 泣した instead. What is the better regular expression?
The parentheses in your character class are half-width (半角) instead of full-width (全角) parentheses.
Replacing them will fix your problem:
import re
re.sub(r"\([^()]*\)", "", '泣(な)き出(だ)した')
# '泣き出した'