sublime text find, copy, change and paste in new line

对着背影说爱祢 提交于 2019-12-03 10:15:46

I believe a regex like this should work:

^(\h*)logging\.info\(([^)]*)\)

Replace with:

$0\n$1print($2)

regex101 demo

Description:

^                 # Beginning of line
(\h*)             # Get any spaces/tabs before the line and store in $1
logging\.info\(   # Match 'logging.info('
([^)]*)           # Get everything between parens
\)                # Match closing paren

Note that the above regex assumes there are no other parens within the logging.info function.

The replace means:

$0                # Whole match
\n                # Newline
$1                # Place the indentation
print(            # 'print('
$2                # The part within the `logging.info` function
)                 # Closing paren
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!