我正在用 Python TKinter 编写一个文本编辑器,目前正在研究语法。我试图使它的格式文本下划线:
\_ **UNDER line This text 0!** \_ (underline the bolded text)
我正在使用正则表达式命令,例如:text.search("\_ [a-zA-Z0-9 !]+ \_", ...)
当前。但是,这也会为下划线以及下划线与文本之间的空格添加下划线。我不想要这个。我正在考虑使用捕获组来解决这个问题,但不知道如何使用 TKinter 来解决这个问题。我目前正在尝试:text.search("\_ ([a-zA-Z0-9 !]+) \_", ...)
,但这不起作用。
任何想法我将如何解决这个问题?