re.sub not replacing all occurrences

前端 未结 4 1989

I\'m not a Python developer, but I\'m using a Python script to convert SQLite to MySQL

The suggested script gets close, but no cigar, as they say.

The line g

4条回答
  •  渐次进展
    2021-01-02 02:43

    using re.sub(r"\bt\b","THIS_IS_TRUE",line):

    In [21]: strs="""INSERT INTO "cars" VALUES(56,'Bugatti Veyron','BUG 1',32,'t','t','2011-12-14 18:39:16.556916','2011-12-15 11:25:03.675058','81');"""
    
    In [22]: print re.sub(r"\bt\b","THIS_IS_TRUE",strs)
    
    INSERT INTO "cars" VALUES(56,'Bugatti Veyron','BUG 1',32,'THIS_IS_TRUE','THIS_IS_TRUE','2011-12-14 18:39:16.556916','2011-12-15 11:25:03.675058','81');
    

提交回复
热议问题