zoukankan      html  css  js  c++  java
  • java正则中的replaceAll()方法

    public String replaceAll​(String replacement)
    

    Replaces every subsequence of the input sequence that matches the pattern with the given replacement string.
    This method first resets this matcher. It then scans the input sequence looking for matches of the pattern. Characters that are not part of any match are appended directly to the result string; each match is replaced in the result by the replacement string. The replacement string may contain references to captured subsequences as in the appendReplacement method.

    Note that backslashes () and dollar signs ($) in the replacement string may cause the results to be different than if it were being treated as a literal replacement string. Dollar signs may be treated as references to captured subsequences as described above, and backslashes are used to escape literal characters in the replacement string.

    Given the regular expression a*b(0个或多个a然后是b), the input "aabfooaabfooabfoob", and the replacement string "-", an invocation of this method on a matcher for that expression would yield the string "-foo-foo-foo-".

    Invoking this method changes this matcher's state. If the matcher is to be used in further matching operations then it should first be reset.

  • 相关阅读:
    redis-mysql连接池
    Java并发编程原理
    利用MyBatis生成器自动生成实体类、DAO接口和Mapping映射文件
    Tomcat 启动图解
    JVM
    Java中的Exception
    Java 设计模式六原则及23中常用设计模式
    Jquery15 插件
    Jquery14 工具函数
    Jquery13 Ajax 进阶
  • 原文地址:https://www.cnblogs.com/fanlumaster/p/13709290.html
Copyright © 2011-2022 走看看