Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在行的开头插入一个字符,但前提是特定行包含一个符号。
例如\t,如果该行包含至少一个;符号,则在一行的开头添加
\t
;
我已经搜索了正则表达式功能,所以显然我可以\t在每行的开头添加一个,但只有当该行包含带有正则表达式的符号时才能插入条件
^(?=.*;)
. matches newline
解释:
^ # beginning of line (?= # positive lookahead, make sure we have after: .* # 0 or more any character but newline ; # semicolon ) # end lookahead
截图(之前):
截图(之后):