当前位置: 首页>>代码示例>>C#>>正文


C# String.replaceAll方法代码示例

本文整理汇总了C#中String.replaceAll方法的典型用法代码示例。如果您正苦于以下问题:C# String.replaceAll方法的具体用法?C# String.replaceAll怎么用?C# String.replaceAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在String的用法示例。


在下文中一共展示了String.replaceAll方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Convert

 public String Convert(String source, SourceDetails details) {
    return source.replaceAll("\r\n", "\n").replaceAll("\r", "\n");
 }
开发者ID:ngallagher,项目名称:simplexml,代码行数:3,代码来源:LanguageConverter.cs

示例2: Comment

 public void Comment(Iterator<String> lines, StringWriter writer, String line) {
    Pattern normalComment = Pattern.compile("^(\\s*)\\*.*$");
    Pattern parameterComment = Pattern.compile("^(\\s*)\\*.*@.*$");
    bool endSummary = false;
    writer.append(line.replaceAll("\\/\\*\\*", "/// <summary>"));
    writer.append("\n");
    while(lines.hasNext()) {
       String nextLine = lines.next();
       nextLine = nextLine.substring(1);
       if(nextLine.matches("^\\s*\\*\\/")) {
          if(!endSummary) {
             writer.append(nextLine.replaceAll("\\*\\/", "/// </summary>"));
          } else {
             writer.append(nextLine.replaceAll("\\*\\/", "///"));
          }
          writer.append("\n");
          return;
       }
       if(!endSummary) {
          Matcher parameterMatch = parameterComment.matcher(nextLine);
          if(parameterMatch.matches()) {
             writer.append(parameterMatch.group(1));
             writer.append("/// </summary>");
             writer.append("\n");
             writer.append(parameterMatch.group(1));
             writer.append(nextLine.replaceAll("^\\s*\\*", "///"));
             writer.append("\n");
             endSummary = true;
          } else {
             Matcher normalMatch = normalComment.matcher(nextLine);
             if(normalMatch.matches()) {
                writer.append(normalMatch.group(1));
                writer.append(nextLine.replaceAll("^\\s*\\*", "///"));
                writer.append("\n");
             }
          }
       } else {
          Matcher normalMatch = normalComment.matcher(nextLine);
          if(normalMatch.matches()) {
             writer.append(normalMatch.group(1));
             writer.append(nextLine.replaceAll("^\\s*\\*", "///"));
             writer.append("\n");
          }else {
             throw new IllegalStateException("Comment does not end well " + nextLine);
          }
       }
    }
 }
开发者ID:ngallagher,项目名称:simplexml,代码行数:48,代码来源:LanguageConverter.cs

示例3: License

 public void License(SourceDetails details, Iterator<String> lines, StringWriter writer, String line) {
    Pattern comment = Pattern.compile("^(\\s*)\\*.*$");
    writer.append(line.replaceAll("\\/\\*", "//"));
    writer.append("\n");
    while(lines.hasNext()) {
       String nextLine = lines.next();
       nextLine = nextLine.substring(1);
       if(nextLine.matches("^\\s*\\*\\/")) {
          writer.append(nextLine.replaceAll("\\*\\/", "//"));
          writer.append("\n");
          return;
       }
       Matcher matcher = comment.matcher(nextLine);
       if(matcher.matches()) {
          if(nextLine.matches(".*\\.java.*")) {
             nextLine = nextLine.replaceAll("\\.java", ".cs");
          }
          writer.append(matcher.group(1));
          writer.append(nextLine.replaceAll("^\\s*\\*", "//"));
          writer.append("\n");
       }else {
          throw new IllegalStateException("Comment does not end well '" + nextLine+"' in file "+details.Source.getCanonicalPath());
       }
    }
 }
开发者ID:ngallagher,项目名称:simplexml,代码行数:25,代码来源:LanguageConverter.cs

示例4: ExpressionMatcher

 public ExpressionMatcher(String pathExpression, ExpressionMatch match) {
    this.segments = pathExpression.replaceAll("^\\/", "").split("\\/");
    this.pattern = Pattern.compile("^(.*)\\[([0-9]+)\\]$");
    this.pathExpression = pathExpression;
    this.match = match;
 }
开发者ID:ngallagher,项目名称:simplexml,代码行数:6,代码来源:ValidationTestCase.cs


注:本文中的String.replaceAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。