代码之家  ›  专栏  ›  技术社区  ›  thSoft

如何用Ant将文件的所有行替换为子字符串?

  •  0
  • thSoft  · 技术社区  · 17 年前

    例如,修剪第一个 n 线条的字符,以便

    123
    1234
    

    成为

    3
    34
    

    ?

    3 回复  |  直到 17 年前
        1
  •  2
  •   FoxyBOA    17 年前
    <target name="test">
            <property name="trim_count" value="2"/>
            <copy file="c:/test.txt" tofile="c:/test2.txt" overwrite="true">
                    <filterchain>
                            <tokenfilter>
                            <linetokenizer/>
                            <replaceregex pattern="^.{1,${trim_count}}(.*)" replace="\1"/>
                            </tokenfilter>
                            <ignoreblank/>
                    </filterchain>
            </copy>
    </target>
    
        2
  •  0
  •   Geo    17 年前

        3
  •  0
  •   dborba    17 年前

    推荐文章