ChevalierLxc
V2EX  ›  问与答

问一个关于 sed 正则替换的问题

  •  
  •   ChevalierLxc · Aug 11, 2023 · 997 views
    This topic created in 1004 days ago, the information mentioned may be changed or developed.

    是这样的,我想替换 sql 里的 params 变成问号,在编辑器里的是可以成功匹配,但是 sed 失效 举例

    select * from tables where id = '1233445561';
    

    结果是

    select * from tables where id = ?;
    

    使用正则

    sed 's/(=\s*\x27)[^\x27]+\x27/=?/g'
    

    该命令无法生效。 但是在编辑器里 (=\s*\x27)[^\x27]+\x27这个正则是可以找到'1233445561'的, 有没有大佬试试?

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   981 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 20:46 · PVG 04:46 · LAX 13:46 · JFK 16:46
    ♥ Do have faith in what you're doing.