zoukankan      html  css  js  c++  java
  • 分析模板的一段简单快速的算法片段

    char[] templateText = txt.ToCharArray();
                
    //ITemplate it = new CleanTemplate();

                List
    <Tag> tags = new List<Tag>();
                
    char[] temp = new char[100];

                
    for (int i = 0; i < templateText.Length; i++)
                {
                    
    if (templateText[i] == '{')
                    {
                        
    if (i > 0 && templateText[i - 1== '\\')
                            
    continue;

                        Tag tag 
    = new Tag();
                        tag.StartIndex 
    = i;
                        context.Response.Write(templateText[i]);

                        
    while (++< templateText.Length && templateText[i] != '}')
                        {
                            
    if (templateText[i] == ' ')
                            {
                                
    if (isFirstSpace)
                                {
                                    isFirstSpace 
    = false;
                                    context.Response.Write(
    " ");
                                }
                                
    continue;
                            }
                            context.Response.Write(templateText[i]);
                        }
                        tag.EndIndex 
    = i;
                        context.Response.Write(templateText[i]);
                        context.Response.Write(
    "<br />");
                    }

                    isFirstSpace 
    = true;
                }

  • 相关阅读:
    系统的访问
    tomcat 和 数据库的连接
    实体类编写规则
    webmagic 爬虫
    docker安装官方Redis镜像并启用密码认证
    解决Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. 问题
    Springboot配置druid报错Failed to bind properties under 'spring.datasource' to javax.sql.DataSource
    阿里云centos7.6搭建SVN远程仓库和Git远程仓库
    java 三大特性封装继承多态
    使用easyui tab需要注意的问题
  • 原文地址:https://www.cnblogs.com/afxcn/p/763225.html
Copyright © 2011-2022 走看看